Finished 2 of usaco
This commit is contained in:
@@ -24,7 +24,6 @@ int main() {
|
||||
map<int, string> index_to_name;
|
||||
|
||||
vector<int> bank(np, 0);
|
||||
vector<int> spendings(np, 0);
|
||||
|
||||
for(int i = 0; i < np; ++i){
|
||||
string s;
|
||||
@@ -40,15 +39,23 @@ int main() {
|
||||
|
||||
fin >> name >> money >> ng;
|
||||
|
||||
// cout << name << " " << money << " " << ng << endl;
|
||||
|
||||
if(ng == 0){
|
||||
continue;
|
||||
}
|
||||
|
||||
vector<string> receivers(ng);
|
||||
for(int j = 0; j < ng; ++i){
|
||||
// cout << ng << endl;
|
||||
|
||||
for(int j = 0; j < ng; ++j){
|
||||
fin >> receivers[j];
|
||||
}
|
||||
|
||||
// for(string s: receivers){
|
||||
// cout << s << " ";
|
||||
// }
|
||||
|
||||
if(money == 0){
|
||||
continue;
|
||||
}
|
||||
@@ -57,13 +64,13 @@ int main() {
|
||||
|
||||
for(const string &receiver : receivers){
|
||||
bank[names_to_index[receiver]] += money_per_person;
|
||||
spendings[names_to_index[receiver]] -= money_per_person;
|
||||
}
|
||||
bank[names_to_index[name]] -= money_per_person * ng;
|
||||
}
|
||||
|
||||
// Printing the output
|
||||
for(int i = 0; i < np; ++i){
|
||||
fout << index_to_name[i] << bank[i] - spendings[i] << endl;
|
||||
fout << index_to_name[i] << " " << bank[i] << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user