Untitled
unknown
plain_text
a year ago
1.4 kB
9
Indexable
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;
}
}Editor is loading...
Leave a Comment