因为set的指针不太会写,所以写了个map但是没有过有人能帮我调一下吗?玄3关。题目
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll Mod=998244353;
map<ll,ll>::iterator iter;
map<ll,ll>mp,mp2;
int n,m,k,u,v,sum;
int main()
{
cin>>n>>m>>k;
for(int i=1,x;i<=n;i++)
cin>>x,mp[x]++;
while(m--)
{
mp2.clear();
int x,y;
cin>>x>>y;
if(x<0)
{
for(iter=mp.end();iter!=mp.begin();iter--)
{
u=iter->first,v=iter->second;
if(u>(-x))
mp2[u+x]=v;
}
mp=mp2;
}
else if(x>0)
{
for(iter=mp.begin();iter!=mp.end();iter++)
{
u=iter->first,v=iter->second;
if(u+x<=k)
mp2[u+x]=v;
else mp2[k]+=v,mp2[1]+=v*(u+x-k);
}
mp=mp2;
}
sum=0;
if(y!=0) mp[y]++;
for(iter=mp.begin();iter!=mp.end();iter++)
sum=(sum+(iter->first)*(iter->second))%Mod;
cout<<sum<<endl;
}
return 0;
}