# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
85065 | 2018-11-18T11:21:35 Z | tjdgus4384 | None (KOI18_arrowH) | C++14 | 50 ms | 16324 KB |
#include<cstdio> #include<vector> #include<algorithm> using namespace std; vector<int> v[100001]; int main() { int x, n, c; long long ans = 0; scanf("%d", &n); for(int i = 0;i < n;i++) { scanf("%d %d", &x, &c); v[c].push_back(x); } for(int i = 1;i <= n;i++) { if(v[i].size() <= 1) continue; sort(v[i].begin(), v[i].end()); ans += v[i][1] - v[i][0]; for(int j = 1;j < v[i].size() - 1;j++) { ans += min(v[i][j] - v[i][j - 1], v[i][j + 1] - v[i][j]); } ans += v[i][v[i].size() - 1] - v[i][v[i].size() - 2]; } printf("%lld", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Correct | 4 ms | 2812 KB | Output is correct |
3 | Correct | 4 ms | 2812 KB | Output is correct |
4 | Correct | 4 ms | 2812 KB | Output is correct |
5 | Correct | 4 ms | 2820 KB | Output is correct |
6 | Correct | 4 ms | 2820 KB | Output is correct |
7 | Correct | 4 ms | 2820 KB | Output is correct |
8 | Correct | 4 ms | 2940 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Correct | 4 ms | 2812 KB | Output is correct |
3 | Correct | 4 ms | 2812 KB | Output is correct |
4 | Correct | 4 ms | 2812 KB | Output is correct |
5 | Correct | 4 ms | 2820 KB | Output is correct |
6 | Correct | 4 ms | 2820 KB | Output is correct |
7 | Correct | 4 ms | 2820 KB | Output is correct |
8 | Correct | 4 ms | 2940 KB | Output is correct |
9 | Correct | 4 ms | 3000 KB | Output is correct |
10 | Correct | 4 ms | 3000 KB | Output is correct |
11 | Correct | 5 ms | 3000 KB | Output is correct |
12 | Correct | 4 ms | 3000 KB | Output is correct |
13 | Correct | 5 ms | 3000 KB | Output is correct |
14 | Correct | 6 ms | 3000 KB | Output is correct |
15 | Correct | 4 ms | 3000 KB | Output is correct |
16 | Correct | 4 ms | 3000 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Correct | 4 ms | 2812 KB | Output is correct |
3 | Correct | 4 ms | 2812 KB | Output is correct |
4 | Correct | 4 ms | 2812 KB | Output is correct |
5 | Correct | 4 ms | 2820 KB | Output is correct |
6 | Correct | 4 ms | 2820 KB | Output is correct |
7 | Correct | 4 ms | 2820 KB | Output is correct |
8 | Correct | 4 ms | 2940 KB | Output is correct |
9 | Correct | 4 ms | 3000 KB | Output is correct |
10 | Correct | 4 ms | 3000 KB | Output is correct |
11 | Correct | 5 ms | 3000 KB | Output is correct |
12 | Correct | 4 ms | 3000 KB | Output is correct |
13 | Correct | 5 ms | 3000 KB | Output is correct |
14 | Correct | 6 ms | 3000 KB | Output is correct |
15 | Correct | 4 ms | 3000 KB | Output is correct |
16 | Correct | 4 ms | 3000 KB | Output is correct |
17 | Correct | 7 ms | 3000 KB | Output is correct |
18 | Correct | 7 ms | 3180 KB | Output is correct |
19 | Correct | 7 ms | 3216 KB | Output is correct |
20 | Correct | 7 ms | 3468 KB | Output is correct |
21 | Correct | 6 ms | 3500 KB | Output is correct |
22 | Correct | 7 ms | 3612 KB | Output is correct |
23 | Correct | 7 ms | 3864 KB | Output is correct |
24 | Correct | 11 ms | 3988 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Correct | 4 ms | 2812 KB | Output is correct |
3 | Correct | 4 ms | 2812 KB | Output is correct |
4 | Correct | 4 ms | 2812 KB | Output is correct |
5 | Correct | 4 ms | 2820 KB | Output is correct |
6 | Correct | 4 ms | 2820 KB | Output is correct |
7 | Correct | 4 ms | 2820 KB | Output is correct |
8 | Correct | 4 ms | 2940 KB | Output is correct |
9 | Correct | 4 ms | 3000 KB | Output is correct |
10 | Correct | 4 ms | 3000 KB | Output is correct |
11 | Correct | 5 ms | 3000 KB | Output is correct |
12 | Correct | 4 ms | 3000 KB | Output is correct |
13 | Correct | 5 ms | 3000 KB | Output is correct |
14 | Correct | 6 ms | 3000 KB | Output is correct |
15 | Correct | 4 ms | 3000 KB | Output is correct |
16 | Correct | 4 ms | 3000 KB | Output is correct |
17 | Correct | 7 ms | 3000 KB | Output is correct |
18 | Correct | 7 ms | 3180 KB | Output is correct |
19 | Correct | 7 ms | 3216 KB | Output is correct |
20 | Correct | 7 ms | 3468 KB | Output is correct |
21 | Correct | 6 ms | 3500 KB | Output is correct |
22 | Correct | 7 ms | 3612 KB | Output is correct |
23 | Correct | 7 ms | 3864 KB | Output is correct |
24 | Correct | 11 ms | 3988 KB | Output is correct |
25 | Correct | 50 ms | 6684 KB | Output is correct |
26 | Correct | 41 ms | 7364 KB | Output is correct |
27 | Correct | 43 ms | 9224 KB | Output is correct |
28 | Correct | 37 ms | 10168 KB | Output is correct |
29 | Correct | 42 ms | 12048 KB | Output is correct |
30 | Correct | 35 ms | 13004 KB | Output is correct |
31 | Correct | 38 ms | 14284 KB | Output is correct |
32 | Correct | 42 ms | 16324 KB | Output is correct |