# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
121094 | 2019-06-26T06:00:29 Z | 윤지학(#2973) | Coin Collecting (JOI19_ho_t4) | C++14 | 2 ms | 384 KB |
#pragma GCC optimize("O3") //#pragma GCC target("arch=skylake") #include <cstdio> int n; int d[100001][2]; inline int abs(int x) { return x < 0 ? -x : x; } int main() { long long s = 0; int i, j, k, l, m, x, y; scanf("%d", &n); for (i = 0; i < n + n; i++) { scanf("%d%d", &x, &y); if (x < 1) { s += 1 - x; x = 1; } if (x > n) { s += x - n; x = n; } if (y < 1) { s += 1 - y; y = 1; } if (y > 2) { s += y - 2; y = 2; } d[x - 1][y - 1]++; } x = y = 0; for (i = 0; i < n; i++) { x += d[i][0] - 1; y += d[i][1] - 1; if (x + y > 0) { if (x < 0) { s -= x; y += x; x = 0; } if (y < 0) { s -= y; x += y; y = 0; } s += x + y; } if (x + y < 0) { if (x > 0) { s += x; y += x; x = 0; } if (y > 0) { s += y; x += y; y = 0; } s -= x + y; } } printf("%lld\n", s + (x > 0 ? x : y)); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Incorrect | 2 ms | 256 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Incorrect | 2 ms | 256 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Incorrect | 2 ms | 256 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |