# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
28130 | 2017-07-15T11:52:54 Z | (#1210, xdoju) | 개미와 비트코인 (FXCUP2_ant) | C++11 | 56 ms | 3072 KB |
#include <cstdio> #include <utility> #include <algorithm> using namespace std; struct ant{ int i, x, d; bool operator< (const ant& rhs) const { return x < rhs.x; } }; ant p[100010]; pair<int, int> s[100010]; int main(){ int N, L, T; scanf("%d%d%d", &N, &L, &T); for(int i = 1; i <= N; i++){ char c; scanf("%d %c", &p[i].x, &c); p[i].i = i; p[i].d = (c == 'L' ? -1 : 1); } int I; scanf("%d", &I); for(int i = 1; i <= N; i++){ int r = p[i].x + p[i].d * T; r %= 2 * L; if(r < 0) r += 2 * L; if(r > L) r = 2 * L - r; s[i].first = r; s[i].second = i; } sort(s + 1, s + N + 1); sort(p + 1, p + N + 1); for(int i = 1; i <= N; i++){ if(s[i].second == I){ printf("%d\n", p[i].i); break; } } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 3072 KB | Output is correct |
2 | Correct | 0 ms | 3072 KB | Output is correct |
3 | Correct | 0 ms | 3072 KB | Output is correct |
4 | Correct | 0 ms | 3072 KB | Output is correct |
5 | Correct | 0 ms | 3072 KB | Output is correct |
6 | Correct | 0 ms | 3072 KB | Output is correct |
7 | Correct | 0 ms | 3072 KB | Output is correct |
8 | Correct | 0 ms | 3072 KB | Output is correct |
9 | Correct | 0 ms | 3072 KB | Output is correct |
10 | Correct | 0 ms | 3072 KB | Output is correct |
11 | Correct | 0 ms | 3072 KB | Output is correct |
12 | Correct | 0 ms | 3072 KB | Output is correct |
13 | Correct | 46 ms | 3072 KB | Output is correct |
14 | Correct | 39 ms | 3072 KB | Output is correct |
15 | Correct | 39 ms | 3072 KB | Output is correct |
16 | Correct | 49 ms | 3072 KB | Output is correct |
17 | Correct | 43 ms | 3072 KB | Output is correct |
18 | Correct | 43 ms | 3072 KB | Output is correct |
19 | Correct | 56 ms | 3072 KB | Output is correct |
20 | Correct | 39 ms | 3072 KB | Output is correct |