# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
106344 | 2019-04-18T00:44:02 Z | tincamatei | Coin Collecting (JOI19_ho_t4) | C++14 | 324 ms | 504 KB |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 20; pair<int, int> points[MAX_N]; int main() { #ifdef HOME FILE *fin = fopen("coin.in", "r"); FILE *fout = fopen("coin.out", "w"); #else FILE *fin = stdin; FILE *fout = stdout; #endif int n; fscanf(fin, "%d", &n); for(int i = 0; i < 2 * n; ++i) fscanf(fin, "%d%d", &points[i].first, &points[i].second); sort(points, points + 2 * n); long long best = 1LL << 60; for(int mask = 0; mask < (1 << (2 * n)); ++mask) { long long rez = 0LL; int lp = 0, up = 0; for(int i = 0; i < 2 * n; ++i) if((1 << i) & mask) { ++lp; rez = rez + llabs(points[i].first - lp) + llabs(points[i].second - 1); } else { ++up; rez = rez + llabs(points[i].first - up) + llabs(points[i].second - 2); } if(lp == n && up == n) best = min(best, rez); } fprintf(fout, "%lld", best); fclose(fin); fclose(fout); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 84 ms | 384 KB | Output is correct |
5 | Correct | 83 ms | 256 KB | Output is correct |
6 | Correct | 116 ms | 384 KB | Output is correct |
7 | Correct | 104 ms | 504 KB | Output is correct |
8 | Correct | 104 ms | 384 KB | Output is correct |
9 | Correct | 88 ms | 356 KB | Output is correct |
10 | Correct | 94 ms | 504 KB | Output is correct |
11 | Correct | 86 ms | 396 KB | Output is correct |
12 | Correct | 93 ms | 504 KB | Output is correct |
13 | Correct | 91 ms | 412 KB | Output is correct |
14 | Correct | 98 ms | 384 KB | Output is correct |
15 | Correct | 111 ms | 384 KB | Output is correct |
16 | Correct | 89 ms | 384 KB | Output is correct |
17 | Correct | 124 ms | 356 KB | Output is correct |
18 | Correct | 100 ms | 376 KB | Output is correct |
19 | Correct | 93 ms | 384 KB | Output is correct |
20 | Correct | 115 ms | 356 KB | Output is correct |
21 | Correct | 95 ms | 352 KB | Output is correct |
22 | Correct | 105 ms | 356 KB | Output is correct |
23 | Correct | 99 ms | 384 KB | Output is correct |
24 | Correct | 96 ms | 376 KB | Output is correct |
25 | Correct | 95 ms | 460 KB | Output is correct |
26 | Correct | 93 ms | 356 KB | Output is correct |
27 | Correct | 91 ms | 356 KB | Output is correct |
28 | Correct | 90 ms | 256 KB | Output is correct |
29 | Correct | 114 ms | 384 KB | Output is correct |
30 | Correct | 94 ms | 384 KB | Output is correct |
31 | Correct | 93 ms | 420 KB | Output is correct |
32 | Correct | 94 ms | 384 KB | Output is correct |
33 | Correct | 83 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 84 ms | 384 KB | Output is correct |
5 | Correct | 83 ms | 256 KB | Output is correct |
6 | Correct | 116 ms | 384 KB | Output is correct |
7 | Correct | 104 ms | 504 KB | Output is correct |
8 | Correct | 104 ms | 384 KB | Output is correct |
9 | Correct | 88 ms | 356 KB | Output is correct |
10 | Correct | 94 ms | 504 KB | Output is correct |
11 | Correct | 86 ms | 396 KB | Output is correct |
12 | Correct | 93 ms | 504 KB | Output is correct |
13 | Correct | 91 ms | 412 KB | Output is correct |
14 | Correct | 98 ms | 384 KB | Output is correct |
15 | Correct | 111 ms | 384 KB | Output is correct |
16 | Correct | 89 ms | 384 KB | Output is correct |
17 | Correct | 124 ms | 356 KB | Output is correct |
18 | Correct | 100 ms | 376 KB | Output is correct |
19 | Correct | 93 ms | 384 KB | Output is correct |
20 | Correct | 115 ms | 356 KB | Output is correct |
21 | Correct | 95 ms | 352 KB | Output is correct |
22 | Correct | 105 ms | 356 KB | Output is correct |
23 | Correct | 99 ms | 384 KB | Output is correct |
24 | Correct | 96 ms | 376 KB | Output is correct |
25 | Correct | 95 ms | 460 KB | Output is correct |
26 | Correct | 93 ms | 356 KB | Output is correct |
27 | Correct | 91 ms | 356 KB | Output is correct |
28 | Correct | 90 ms | 256 KB | Output is correct |
29 | Correct | 114 ms | 384 KB | Output is correct |
30 | Correct | 94 ms | 384 KB | Output is correct |
31 | Correct | 93 ms | 420 KB | Output is correct |
32 | Correct | 94 ms | 384 KB | Output is correct |
33 | Correct | 83 ms | 384 KB | Output is correct |
34 | Execution timed out | 324 ms | 384 KB | Time limit exceeded (wall clock) |
35 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 84 ms | 384 KB | Output is correct |
5 | Correct | 83 ms | 256 KB | Output is correct |
6 | Correct | 116 ms | 384 KB | Output is correct |
7 | Correct | 104 ms | 504 KB | Output is correct |
8 | Correct | 104 ms | 384 KB | Output is correct |
9 | Correct | 88 ms | 356 KB | Output is correct |
10 | Correct | 94 ms | 504 KB | Output is correct |
11 | Correct | 86 ms | 396 KB | Output is correct |
12 | Correct | 93 ms | 504 KB | Output is correct |
13 | Correct | 91 ms | 412 KB | Output is correct |
14 | Correct | 98 ms | 384 KB | Output is correct |
15 | Correct | 111 ms | 384 KB | Output is correct |
16 | Correct | 89 ms | 384 KB | Output is correct |
17 | Correct | 124 ms | 356 KB | Output is correct |
18 | Correct | 100 ms | 376 KB | Output is correct |
19 | Correct | 93 ms | 384 KB | Output is correct |
20 | Correct | 115 ms | 356 KB | Output is correct |
21 | Correct | 95 ms | 352 KB | Output is correct |
22 | Correct | 105 ms | 356 KB | Output is correct |
23 | Correct | 99 ms | 384 KB | Output is correct |
24 | Correct | 96 ms | 376 KB | Output is correct |
25 | Correct | 95 ms | 460 KB | Output is correct |
26 | Correct | 93 ms | 356 KB | Output is correct |
27 | Correct | 91 ms | 356 KB | Output is correct |
28 | Correct | 90 ms | 256 KB | Output is correct |
29 | Correct | 114 ms | 384 KB | Output is correct |
30 | Correct | 94 ms | 384 KB | Output is correct |
31 | Correct | 93 ms | 420 KB | Output is correct |
32 | Correct | 94 ms | 384 KB | Output is correct |
33 | Correct | 83 ms | 384 KB | Output is correct |
34 | Execution timed out | 324 ms | 384 KB | Time limit exceeded (wall clock) |
35 | Halted | 0 ms | 0 KB | - |