#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
1104 KB |
Output is correct |
2 |
Correct |
23 ms |
1104 KB |
Output is correct |
3 |
Correct |
23 ms |
1104 KB |
Output is correct |
4 |
Correct |
26 ms |
1104 KB |
Output is correct |
5 |
Correct |
20 ms |
1104 KB |
Output is correct |
6 |
Correct |
22 ms |
1104 KB |
Output is correct |
7 |
Correct |
19 ms |
1104 KB |
Output is correct |
8 |
Correct |
19 ms |
1104 KB |
Output is correct |
9 |
Correct |
20 ms |
1104 KB |
Output is correct |
10 |
Correct |
21 ms |
1104 KB |
Output is correct |
11 |
Correct |
11 ms |
1104 KB |
Output is correct |
12 |
Correct |
13 ms |
1104 KB |
Output is correct |
13 |
Correct |
4 ms |
1104 KB |
Output is correct |
14 |
Correct |
7 ms |
1104 KB |
Output is correct |
15 |
Correct |
11 ms |
1104 KB |
Output is correct |
16 |
Correct |
25 ms |
1104 KB |
Output is correct |
17 |
Correct |
28 ms |
1104 KB |
Output is correct |
18 |
Correct |
19 ms |
1104 KB |
Output is correct |
19 |
Correct |
8 ms |
1104 KB |
Output is correct |
20 |
Correct |
20 ms |
1104 KB |
Output is correct |
21 |
Correct |
5 ms |
1104 KB |
Output is correct |
22 |
Correct |
5 ms |
1104 KB |
Output is correct |
23 |
Correct |
21 ms |
1104 KB |
Output is correct |
24 |
Correct |
24 ms |
1104 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3000 ms |
1104 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |