Submission #15559

# Submission time Handle Problem Language Result Execution time Memory
15559 2015-07-12T17:48:27 Z cki86201 통로 위의 개미 (kriii3_X) C++
30 / 85
180 ms 1096 KB
#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], C[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);
			int w = (b == 1 ? a : 2 * L - a);
			ll rew = re(w - t, 2 * L);
			W[++cw] = rew;
			for (int j = 1; j < cw; j++){
				int tmp = L - abs(L - re(W[j] + t, 2 * L));
				if (L - abs(L - w) > tmp)C[cw]++;
			}
			for (int j = 1; j < cw; j++)if (C[j] >= C[cw])C[j]++;
		}
		else{
			int a;
			scanf("%d", &a);
			int j;
			for (j = 1; j <= cw; j++){
				tW[j] = L - abs(L - re((W[j] + t), 2 * L));
			}
			std::sort(tW + 1, tW + 1 + cw);
			printf("%d\n", tW[C[a]+1]);
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 19 ms 1096 KB Output is correct
2 Correct 20 ms 1096 KB Output is correct
3 Correct 20 ms 1096 KB Output is correct
4 Correct 21 ms 1096 KB Output is correct
5 Correct 19 ms 1096 KB Output is correct
6 Correct 19 ms 1096 KB Output is correct
7 Correct 19 ms 1096 KB Output is correct
8 Correct 19 ms 1096 KB Output is correct
9 Correct 19 ms 1096 KB Output is correct
10 Correct 20 ms 1096 KB Output is correct
11 Correct 13 ms 1096 KB Output is correct
12 Correct 12 ms 1096 KB Output is correct
13 Correct 10 ms 1096 KB Output is correct
14 Correct 12 ms 1096 KB Output is correct
15 Correct 12 ms 1096 KB Output is correct
16 Correct 21 ms 1096 KB Output is correct
17 Correct 14 ms 1096 KB Output is correct
18 Correct 17 ms 1096 KB Output is correct
19 Correct 15 ms 1096 KB Output is correct
20 Correct 17 ms 1096 KB Output is correct
21 Correct 9 ms 1096 KB Output is correct
22 Correct 9 ms 1096 KB Output is correct
23 Correct 20 ms 1096 KB Output is correct
24 Correct 13 ms 1096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 180 ms 1096 KB Output isn't correct
2 Halted 0 ms 0 KB -