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>
using namespace std;
pair<long long,long long> arix[1010];
int order[1010];
int tp=0;
int L,Q;
void update(long long int t)
{
t%=2*L;
for(int i=0;i<tp;i++)
{
arix[i].first+=arix[i].second*t;
while(arix[i].first<0 || arix[i].first>L)
{
if(arix[i].first<0)
{
arix[i].first*=-1;
arix[i].second*=-1;
}
else
{
arix[i].first=2*L-arix[i].first;
arix[i].second*=-1;
}
}
}
sort(arix,arix+tp);
return;
}
int main()
{
scanf("%d%d",&L,&Q);
long long int pt=0;
for(int i=0;i<Q;i++)
{
long long int t;
scanf("%lld",&t);
update(t-pt);
pt=t;
int tt;
scanf("%d",&tt);
if(tt==1)
{
int x,d;
scanf("%d%d",&x,&d);
arix[tp]=make_pair(x,d);
for(int i=0;i<tp;i++)
if(arix[i].first<x)
order[tp]++;
for(int i=0;i<tp;i++)
if(order[i]>=order[tp]) order[i]++;
tp++;
}
else
{
int c;
scanf("%d",&c);
printf("%lld\n",arix[order[c-1]].first);
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |