# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
62756 | 2018-07-30T01:57:38 Z | jjwdi0 | None (KOI18_arrowH) | C++11 | 86 ms | 16688 KB |
#include <bits/stdc++.h> using namespace std; int N; vector<int> v[100005]; long long ans; int main() { scanf("%d", &N); for(int i=1, x, y; i<=N; i++) scanf("%d %d", &x, &y), v[y].push_back(x); for(int i=1; i<=N; i++) sort(v[i].begin(), v[i].end()); for(int i=1; i<=N; i++) { if(v[i].size() == 1) continue; for(int j=0; j<v[i].size(); j++) { if(j == 0) ans += 1LL * (v[i][j+1] - v[i][j]); else if(j == v[i].size() - 1) ans += 1LL * (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); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2680 KB | Output is correct |
2 | Correct | 5 ms | 2792 KB | Output is correct |
3 | Correct | 5 ms | 2792 KB | Output is correct |
4 | Correct | 5 ms | 2852 KB | Output is correct |
5 | Correct | 5 ms | 2852 KB | Output is correct |
6 | Correct | 5 ms | 3008 KB | Output is correct |
7 | Correct | 4 ms | 3008 KB | Output is correct |
8 | Correct | 5 ms | 3008 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2680 KB | Output is correct |
2 | Correct | 5 ms | 2792 KB | Output is correct |
3 | Correct | 5 ms | 2792 KB | Output is correct |
4 | Correct | 5 ms | 2852 KB | Output is correct |
5 | Correct | 5 ms | 2852 KB | Output is correct |
6 | Correct | 5 ms | 3008 KB | Output is correct |
7 | Correct | 4 ms | 3008 KB | Output is correct |
8 | Correct | 5 ms | 3008 KB | Output is correct |
9 | Correct | 5 ms | 3008 KB | Output is correct |
10 | Correct | 5 ms | 3028 KB | Output is correct |
11 | Correct | 6 ms | 3060 KB | Output is correct |
12 | Correct | 6 ms | 3084 KB | Output is correct |
13 | Correct | 7 ms | 3248 KB | Output is correct |
14 | Correct | 7 ms | 3332 KB | Output is correct |
15 | Correct | 6 ms | 3356 KB | Output is correct |
16 | Correct | 7 ms | 3356 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2680 KB | Output is correct |
2 | Correct | 5 ms | 2792 KB | Output is correct |
3 | Correct | 5 ms | 2792 KB | Output is correct |
4 | Correct | 5 ms | 2852 KB | Output is correct |
5 | Correct | 5 ms | 2852 KB | Output is correct |
6 | Correct | 5 ms | 3008 KB | Output is correct |
7 | Correct | 4 ms | 3008 KB | Output is correct |
8 | Correct | 5 ms | 3008 KB | Output is correct |
9 | Correct | 5 ms | 3008 KB | Output is correct |
10 | Correct | 5 ms | 3028 KB | Output is correct |
11 | Correct | 6 ms | 3060 KB | Output is correct |
12 | Correct | 6 ms | 3084 KB | Output is correct |
13 | Correct | 7 ms | 3248 KB | Output is correct |
14 | Correct | 7 ms | 3332 KB | Output is correct |
15 | Correct | 6 ms | 3356 KB | Output is correct |
16 | Correct | 7 ms | 3356 KB | Output is correct |
17 | Correct | 10 ms | 3432 KB | Output is correct |
18 | Correct | 10 ms | 3556 KB | Output is correct |
19 | Correct | 9 ms | 3672 KB | Output is correct |
20 | Correct | 12 ms | 3908 KB | Output is correct |
21 | Correct | 10 ms | 3924 KB | Output is correct |
22 | Correct | 11 ms | 4036 KB | Output is correct |
23 | Correct | 10 ms | 4272 KB | Output is correct |
24 | Correct | 10 ms | 4396 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2680 KB | Output is correct |
2 | Correct | 5 ms | 2792 KB | Output is correct |
3 | Correct | 5 ms | 2792 KB | Output is correct |
4 | Correct | 5 ms | 2852 KB | Output is correct |
5 | Correct | 5 ms | 2852 KB | Output is correct |
6 | Correct | 5 ms | 3008 KB | Output is correct |
7 | Correct | 4 ms | 3008 KB | Output is correct |
8 | Correct | 5 ms | 3008 KB | Output is correct |
9 | Correct | 5 ms | 3008 KB | Output is correct |
10 | Correct | 5 ms | 3028 KB | Output is correct |
11 | Correct | 6 ms | 3060 KB | Output is correct |
12 | Correct | 6 ms | 3084 KB | Output is correct |
13 | Correct | 7 ms | 3248 KB | Output is correct |
14 | Correct | 7 ms | 3332 KB | Output is correct |
15 | Correct | 6 ms | 3356 KB | Output is correct |
16 | Correct | 7 ms | 3356 KB | Output is correct |
17 | Correct | 10 ms | 3432 KB | Output is correct |
18 | Correct | 10 ms | 3556 KB | Output is correct |
19 | Correct | 9 ms | 3672 KB | Output is correct |
20 | Correct | 12 ms | 3908 KB | Output is correct |
21 | Correct | 10 ms | 3924 KB | Output is correct |
22 | Correct | 11 ms | 4036 KB | Output is correct |
23 | Correct | 10 ms | 4272 KB | Output is correct |
24 | Correct | 10 ms | 4396 KB | Output is correct |
25 | Correct | 82 ms | 7116 KB | Output is correct |
26 | Correct | 54 ms | 7720 KB | Output is correct |
27 | Correct | 86 ms | 9580 KB | Output is correct |
28 | Correct | 54 ms | 10616 KB | Output is correct |
29 | Correct | 67 ms | 12244 KB | Output is correct |
30 | Correct | 52 ms | 13412 KB | Output is correct |
31 | Correct | 49 ms | 14712 KB | Output is correct |
32 | Correct | 56 ms | 16688 KB | Output is correct |