This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<cstdio>
#include<algorithm>
long long a[1111];
int an;
int p[1111];
long long d[1111];
int main()
{
long long t;
int i,j,n,m,x,y,tt;
scanf("%d%d",&n,&m);
while(m--)
{
scanf("%lld%d",&t,&tt);
for(i=0;i<an;i++)
{
d[i]=(a[i]+t+n+n)%(n+n);
if(d[i]>n)d[i]=n+n-d[i];
}
std::sort(d,d+an);
if(tt==1)
{
scanf("%d%d",&x,&y);
for(i=0;i<an;i++)if(d[i]>x)break;
for(j=0;j<an;j++)if(p[j]>=i)p[j]++;
p[an]=i;
if(y<0)x=n+n-x;
a[an]=(x-t)%(n+n);
an++;
}
else
{
scanf("%d",&x);
printf("%lld\n",d[p[x-1]]);
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |