Submission #15557

#TimeUsernameProblemLanguageResultExecution timeMemory
15557cki86201통로 위의 개미 (kriii3_X)C++98
0 / 85
6 ms1092 KiB
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<math.h> #include<algorithm> typedef long long ll; ll re(ll x, ll y){ return (x % y + y) % y; } int L, Q; int W[1002], cw, tW[1002]; int main(){ scanf("%d%d", &L, &Q); int i; for (i = 1; i <= Q; i++){ ll t; scanf("%lld", &t); int p; scanf("%d", &p); if (p == 1){ int a, b; scanf("%d%d", &a, &b); ll w = (b == 1 ? a : 2 * L - a) - t; w = re(w, 2 * L); W[++cw] = w; } else{ int a; scanf("%d", &a); int j; int cnt = 0; for (j = 1; j <= cw; j++){ if (abs(L - W[j]) > abs(L - W[a]))cnt++; } for (j = 1; j <= cw; j++){ int tmp = (int)((W[j] + t) % (2 * L)); if (tmp < L)tW[j] = tmp; else tW[j] = 2 * L - tmp; } std::sort(tW + 1, tW + 1 + cw); printf("%d\n", tW[cw - cnt]); } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...