# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
121088 | 2019-06-26T05:34:03 Z | 윤지학(#2973) | Coin Collecting (JOI19_ho_t4) | C++14 | 2 ms | 384 KB |
#pragma GCC optimize("O3") //#pragma GCC target("arch=skylake") #include <cstdio> #include <algorithm> #define x first #define y second using namespace std; typedef pair<int, int> pii; int n; pii a[2002]; inline int abs(int x) { return x < 0 ? -x : x; } int main() { long long s = 0; int i, j, k, l, m; scanf("%d", &n); for (i = 0; i < n + n; i++) { scanf("%d%d", &a[i].x, &a[i].y); if (a[i].x < 1) { s += 1 - a[i].x; a[i].x = 1; } if (a[i].x > n) { s += a[i].x - n; a[i].x = n; } if (a[i].y < 1) { s += 1 - a[i].y; a[i].y = 1; } if (a[i].y > 2) { s += a[i].y - 2; a[i].y = 2; } } sort(a, a + n + n); for (i = 0; i < n + n; i++) s += abs(a[i].x - (i >> 1) - 1); for (i = 0; i < n + n;) { k = l = 0; for (j = i; j < n + n && (a[i].x - (i >> 1) - 1ll) * (a[j].x - (j >> 1) - 1ll) >= 0; j++) { if (a[j].y == 1) k++; else l++; } while (i < j) { if (i & 1) { if (m == 0) { if (k) k--; else { l--; s++; } } else { if (l) l--; else { k--; s++; } } } else { if (k) { k--; m = 1; } else { l--; m = 0; } } i++; } } printf("%lld\n", s); }
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 | 256 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 | 384 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 | 256 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 | 384 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 | 256 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 | 384 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |