# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
52653 | 2018-06-26T10:41:07 Z | SpaimaCarpatilor | Teleporters (IOI08_teleporters) | C++17 | 749 ms | 131136 KB |
#include<bits/stdc++.h> using namespace std; int N, M, nr, v[2000009], nxt[2000009], gain[2000009], ap[2000009]; const int K = 2000001; int main () { //freopen ("input", "r", stdin); //freopen ("output", "w", stdout); scanf ("%d %d", &N, &M); for (int i=1; i<K; i++) nxt[i] = i + 1; nxt[K] = 1; for (int i=1; i<=N; i++) { int x, y; scanf ("%d %d", &x, &y); gain[x] = gain[y] = 1; swap (nxt[x], nxt[y]); } for (int i=1; i<=K; i++) if (ap[i] == 0) { int j = i, s = 0; while (ap[j] == 0) ap[j] = 1, s += gain[j], j = nxt[j]; v[++nr] = s; } sort (v + 2, v + nr + 1); while (M > 0 && nr > 1) v[1] += v[nr] + 2, nr --, M --; if (M > 0) v[1] += 2 * M - M % 2; printf ("%d\n", v[1]); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 15992 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 28 ms | 16104 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 16104 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 28 ms | 16104 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 16144 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 16144 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 16232 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 28 ms | 16232 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 16260 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 16260 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 16260 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 16304 KB | Output is correct |
2 | Correct | 32 ms | 16456 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 31 ms | 16456 KB | Output is correct |
2 | Correct | 32 ms | 16852 KB | Output is correct |
3 | Correct | 35 ms | 16996 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 16996 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 34 ms | 16996 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 92 ms | 19044 KB | Output is correct |
2 | Correct | 264 ms | 27948 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 180 ms | 27948 KB | Output is correct |
2 | Correct | 343 ms | 29448 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 470 ms | 30588 KB | Output is correct |
2 | Correct | 508 ms | 30876 KB | Output is correct |
3 | Correct | 503 ms | 42484 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 606 ms | 42484 KB | Output is correct |
2 | Correct | 749 ms | 56520 KB | Output is correct |
3 | Correct | 641 ms | 68956 KB | Output is correct |
4 | Correct | 631 ms | 83508 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 673 ms | 85920 KB | Output is correct |
2 | Correct | 697 ms | 100856 KB | Output is correct |
3 | Correct | 288 ms | 116572 KB | Output is correct |
4 | Correct | 622 ms | 131136 KB | Output is correct |