Submission #15484

#TimeUsernameProblemLanguageResultExecution timeMemory
15484progressive통로 위의 개미 (kriii3_X)C++14
30 / 85
3000 ms1104 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...