# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
121089 | 2019-06-26T05:35:28 Z | 김세빈(#2968) | Coin Collecting (JOI19_ho_t4) | C++14 | 2 ms | 384 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll S[101010][2]; ll n, s0, s1, ans; int main() { ll i, x, y; scanf("%lld", &n); for(i=0; i<n+n; i++){ scanf("%lld%lld", &x, &y); y --; if(x < 1) ans += 1 - x, x = 1; if(x > n) ans += x - n, x = n; if(y < 0) ans += 0 - y, y = 0; if(y > 1) ans += y - 1, y = 1; S[x][y] ++; } for(i=1; i<=n; i++){ s0 += S[i][0] - 1; s1 += S[i][1] - 1; if(s0 > 0 && s1 < 0){ if(s0 > -s1) ans -= s1, s0 += s1, s1 = 0; else ans += s0, s1 += s0, s0 = 0; } else{ if(-s0 > s1) ans += s1, s0 += s1, s1 = 0; else ans -= s0, s1 += s0, s0 = 0; } ans += abs(s0 + s1); } printf("%lld\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 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 | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 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 | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Incorrect | 2 ms | 256 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |