# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
65657 | 2018-08-08T11:05:16 Z | sebinkim | None (KOI18_arrowH) | C++14 | 71 ms | 17180 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector <ll> V[101010]; ll n, ans; int main() { ll i, j, a, b; scanf("%lld", &n); for(i=0; i<n; i++){ scanf("%lld%lld", &a, &b); V[b].push_back(a); } for(i=1; i<=n; i++){ if(V[i].size() < 2) continue; sort(V[i].begin(), V[i].end()); for(j=0; j<V[i].size(); j++){ if(j == 0) ans += V[i][j+1] - V[i][j]; else if(j + 1 == V[i].size()) ans += V[i][j] - V[i][j-1]; else ans += min(V[i][j+1] - V[i][j], V[i][j] - V[i][j-1]); } } printf("%lld\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2684 KB | Output is correct |
2 | Correct | 4 ms | 2728 KB | Output is correct |
3 | Correct | 5 ms | 2768 KB | Output is correct |
4 | Correct | 5 ms | 2940 KB | Output is correct |
5 | Correct | 4 ms | 2940 KB | Output is correct |
6 | Correct | 6 ms | 3052 KB | Output is correct |
7 | Correct | 4 ms | 3052 KB | Output is correct |
8 | Correct | 5 ms | 3052 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2684 KB | Output is correct |
2 | Correct | 4 ms | 2728 KB | Output is correct |
3 | Correct | 5 ms | 2768 KB | Output is correct |
4 | Correct | 5 ms | 2940 KB | Output is correct |
5 | Correct | 4 ms | 2940 KB | Output is correct |
6 | Correct | 6 ms | 3052 KB | Output is correct |
7 | Correct | 4 ms | 3052 KB | Output is correct |
8 | Correct | 5 ms | 3052 KB | Output is correct |
9 | Correct | 5 ms | 3052 KB | Output is correct |
10 | Correct | 6 ms | 3052 KB | Output is correct |
11 | Correct | 6 ms | 3176 KB | Output is correct |
12 | Correct | 5 ms | 3176 KB | Output is correct |
13 | Correct | 6 ms | 3180 KB | Output is correct |
14 | Correct | 5 ms | 3204 KB | Output is correct |
15 | Correct | 7 ms | 3360 KB | Output is correct |
16 | Correct | 5 ms | 3360 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2684 KB | Output is correct |
2 | Correct | 4 ms | 2728 KB | Output is correct |
3 | Correct | 5 ms | 2768 KB | Output is correct |
4 | Correct | 5 ms | 2940 KB | Output is correct |
5 | Correct | 4 ms | 2940 KB | Output is correct |
6 | Correct | 6 ms | 3052 KB | Output is correct |
7 | Correct | 4 ms | 3052 KB | Output is correct |
8 | Correct | 5 ms | 3052 KB | Output is correct |
9 | Correct | 5 ms | 3052 KB | Output is correct |
10 | Correct | 6 ms | 3052 KB | Output is correct |
11 | Correct | 6 ms | 3176 KB | Output is correct |
12 | Correct | 5 ms | 3176 KB | Output is correct |
13 | Correct | 6 ms | 3180 KB | Output is correct |
14 | Correct | 5 ms | 3204 KB | Output is correct |
15 | Correct | 7 ms | 3360 KB | Output is correct |
16 | Correct | 5 ms | 3360 KB | Output is correct |
17 | Correct | 12 ms | 3560 KB | Output is correct |
18 | Correct | 10 ms | 3684 KB | Output is correct |
19 | Correct | 7 ms | 3728 KB | Output is correct |
20 | Correct | 12 ms | 4036 KB | Output is correct |
21 | Correct | 10 ms | 4200 KB | Output is correct |
22 | Correct | 9 ms | 4200 KB | Output is correct |
23 | Correct | 8 ms | 4292 KB | Output is correct |
24 | Correct | 10 ms | 4420 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2684 KB | Output is correct |
2 | Correct | 4 ms | 2728 KB | Output is correct |
3 | Correct | 5 ms | 2768 KB | Output is correct |
4 | Correct | 5 ms | 2940 KB | Output is correct |
5 | Correct | 4 ms | 2940 KB | Output is correct |
6 | Correct | 6 ms | 3052 KB | Output is correct |
7 | Correct | 4 ms | 3052 KB | Output is correct |
8 | Correct | 5 ms | 3052 KB | Output is correct |
9 | Correct | 5 ms | 3052 KB | Output is correct |
10 | Correct | 6 ms | 3052 KB | Output is correct |
11 | Correct | 6 ms | 3176 KB | Output is correct |
12 | Correct | 5 ms | 3176 KB | Output is correct |
13 | Correct | 6 ms | 3180 KB | Output is correct |
14 | Correct | 5 ms | 3204 KB | Output is correct |
15 | Correct | 7 ms | 3360 KB | Output is correct |
16 | Correct | 5 ms | 3360 KB | Output is correct |
17 | Correct | 12 ms | 3560 KB | Output is correct |
18 | Correct | 10 ms | 3684 KB | Output is correct |
19 | Correct | 7 ms | 3728 KB | Output is correct |
20 | Correct | 12 ms | 4036 KB | Output is correct |
21 | Correct | 10 ms | 4200 KB | Output is correct |
22 | Correct | 9 ms | 4200 KB | Output is correct |
23 | Correct | 8 ms | 4292 KB | Output is correct |
24 | Correct | 10 ms | 4420 KB | Output is correct |
25 | Correct | 70 ms | 7604 KB | Output is correct |
26 | Correct | 48 ms | 8308 KB | Output is correct |
27 | Correct | 71 ms | 10112 KB | Output is correct |
28 | Correct | 46 ms | 11160 KB | Output is correct |
29 | Correct | 63 ms | 12860 KB | Output is correct |
30 | Correct | 54 ms | 13864 KB | Output is correct |
31 | Correct | 46 ms | 15140 KB | Output is correct |
32 | Correct | 61 ms | 17180 KB | Output is correct |