HELP ME
查看原帖
HELP ME
953589
coderJerry楼主2024/10/2 09:41

rt,样例全过,但 0pts。

用 un[x] 存的每个数去重多少次,如有低级错误喷的轻一点可以吗

#include <bits/stdc++.h>
#define int long long
using namespace std;
map<int,int> mp,un;
int q,op,x,y,cnt=0;
signed main(){
    cin>>q;
    while(q--){
        cin>>op;
        if(op==1){
            cin>>x>>y;
            if(un[x]!=cnt&&mp[x]!=0){
                mp[x]=1;
                un[x]++;
            }
            mp[x]+=y;
        }
        if(op==2){
            cin>>x>>y;
            if(un[x]!=cnt&&mp[x]!=0){
                mp[x]=1;
                un[x]++;
            }
            mp[x]-=min(mp[x],y);
        }
        if(op==3) cnt++;
        if(op==4){
            cin>>x;
            if(un[x]!=cnt&&mp[x]!=0){
                mp[x]=1;
                un[x]++;
            }
            cout<<mp[x]<<endl;
        }
    }
    return 0;
}
2024/10/2 09:41
加载中...