Untitled
unknown
plain_text
24 days ago
1.4 kB
3
Indexable
Never
int n; cin >> n; string pas; cin >> pas; vector<string>v(n); map<int,pair<string,ll>>mp; map<string ,int>iid; for (int i = 0; i < n; ++i) { cin >> v[i]; mp[i+1].fi = v[i]; iid[v[i]] = i+1; } int q; cin >> q; while(q--){ string op; cin >> op; if(op == "bonus"){ int id , val; cin >> id >> val; string p; cin >> p; if(p == pas){ cout<<"Updated successfully"<<el; mp[id].se += val; }else{ cout<<"Wrong password please try again"<<el; } cout<<"---"<<el; }else{ vector<item>x; for(auto i : mp){ if(i.se.se != 0){ x.push_back({i.se.se, iid[i.se.fi], i.se.fi}); } } sort(all(x) , comp); ll j = 1; for (int i = 0; i < sz(x); ++i) { if(i){ if(x[i].f != x[i-1].f)j++; cout<<j<< ' ' << x[i].tr << " " << x[i].name << " " << x[i].f << el; }else{ cout<<1 << ' ' << x[i].tr << " " << x[i].name << " " << x[i].f << el; } } cout<<"---"<<el; } }
Leave a Comment