# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
63302 | 2018-08-01T10:04:56 Z | kjp4155 | None (KOI18_arrowH) | C++17 | 80 ms | 16828 KB |
#include <stdio.h> #include <algorithm> #include <utility> #include <vector> using namespace std; typedef long long ll; int N; vector<ll> v[100500]; int main(){ scanf("%d",&N); for(int i=1;i<=N;i++){ ll x,y; scanf("%lld%lld",&x,&y); v[y].push_back(x); } ll ans = 0; // 각 색깔별로 점들을 정렬한 뒤, 각 점마다 가장 가까운 점까지의 거리를 답에 더한다 for(int i=1;i<=N;i++){ // 색 i에 점이 한 개 이하라면 넘어간다 if( v[i].size() <= 1 ) continue; sort(v[i].begin(), v[i].end()); // 색 i의 j번째 점을 처리 for(int j=0;j<v[i].size();j++){ ll mn = 1e18; if( j > 0 ) mn = min( mn, v[i][j]-v[i][j-1] ); if( j < v[i].size()-1 ) mn = min( mn, v[i][j+1]-v[i][j] ); ans += mn; } } printf("%lld\n",ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2684 KB | Output is correct |
2 | Correct | 5 ms | 2684 KB | Output is correct |
3 | Correct | 5 ms | 2744 KB | Output is correct |
4 | Correct | 4 ms | 2824 KB | Output is correct |
5 | Correct | 5 ms | 2904 KB | Output is correct |
6 | Correct | 4 ms | 2996 KB | Output is correct |
7 | Correct | 4 ms | 2996 KB | Output is correct |
8 | Correct | 4 ms | 2996 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2684 KB | Output is correct |
2 | Correct | 5 ms | 2684 KB | Output is correct |
3 | Correct | 5 ms | 2744 KB | Output is correct |
4 | Correct | 4 ms | 2824 KB | Output is correct |
5 | Correct | 5 ms | 2904 KB | Output is correct |
6 | Correct | 4 ms | 2996 KB | Output is correct |
7 | Correct | 4 ms | 2996 KB | Output is correct |
8 | Correct | 4 ms | 2996 KB | Output is correct |
9 | Correct | 6 ms | 3028 KB | Output is correct |
10 | Correct | 6 ms | 3028 KB | Output is correct |
11 | Correct | 5 ms | 3120 KB | Output is correct |
12 | Correct | 5 ms | 3120 KB | Output is correct |
13 | Correct | 5 ms | 3120 KB | Output is correct |
14 | Correct | 7 ms | 3120 KB | Output is correct |
15 | Correct | 6 ms | 3120 KB | Output is correct |
16 | Correct | 6 ms | 3120 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2684 KB | Output is correct |
2 | Correct | 5 ms | 2684 KB | Output is correct |
3 | Correct | 5 ms | 2744 KB | Output is correct |
4 | Correct | 4 ms | 2824 KB | Output is correct |
5 | Correct | 5 ms | 2904 KB | Output is correct |
6 | Correct | 4 ms | 2996 KB | Output is correct |
7 | Correct | 4 ms | 2996 KB | Output is correct |
8 | Correct | 4 ms | 2996 KB | Output is correct |
9 | Correct | 6 ms | 3028 KB | Output is correct |
10 | Correct | 6 ms | 3028 KB | Output is correct |
11 | Correct | 5 ms | 3120 KB | Output is correct |
12 | Correct | 5 ms | 3120 KB | Output is correct |
13 | Correct | 5 ms | 3120 KB | Output is correct |
14 | Correct | 7 ms | 3120 KB | Output is correct |
15 | Correct | 6 ms | 3120 KB | Output is correct |
16 | Correct | 6 ms | 3120 KB | Output is correct |
17 | Correct | 11 ms | 3400 KB | Output is correct |
18 | Correct | 8 ms | 3524 KB | Output is correct |
19 | Correct | 8 ms | 3640 KB | Output is correct |
20 | Correct | 9 ms | 3748 KB | Output is correct |
21 | Correct | 7 ms | 3892 KB | Output is correct |
22 | Correct | 11 ms | 3892 KB | Output is correct |
23 | Correct | 13 ms | 4112 KB | Output is correct |
24 | Correct | 8 ms | 4236 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2684 KB | Output is correct |
2 | Correct | 5 ms | 2684 KB | Output is correct |
3 | Correct | 5 ms | 2744 KB | Output is correct |
4 | Correct | 4 ms | 2824 KB | Output is correct |
5 | Correct | 5 ms | 2904 KB | Output is correct |
6 | Correct | 4 ms | 2996 KB | Output is correct |
7 | Correct | 4 ms | 2996 KB | Output is correct |
8 | Correct | 4 ms | 2996 KB | Output is correct |
9 | Correct | 6 ms | 3028 KB | Output is correct |
10 | Correct | 6 ms | 3028 KB | Output is correct |
11 | Correct | 5 ms | 3120 KB | Output is correct |
12 | Correct | 5 ms | 3120 KB | Output is correct |
13 | Correct | 5 ms | 3120 KB | Output is correct |
14 | Correct | 7 ms | 3120 KB | Output is correct |
15 | Correct | 6 ms | 3120 KB | Output is correct |
16 | Correct | 6 ms | 3120 KB | Output is correct |
17 | Correct | 11 ms | 3400 KB | Output is correct |
18 | Correct | 8 ms | 3524 KB | Output is correct |
19 | Correct | 8 ms | 3640 KB | Output is correct |
20 | Correct | 9 ms | 3748 KB | Output is correct |
21 | Correct | 7 ms | 3892 KB | Output is correct |
22 | Correct | 11 ms | 3892 KB | Output is correct |
23 | Correct | 13 ms | 4112 KB | Output is correct |
24 | Correct | 8 ms | 4236 KB | Output is correct |
25 | Correct | 80 ms | 7316 KB | Output is correct |
26 | Correct | 61 ms | 8072 KB | Output is correct |
27 | Correct | 58 ms | 9932 KB | Output is correct |
28 | Correct | 43 ms | 10896 KB | Output is correct |
29 | Correct | 54 ms | 12656 KB | Output is correct |
30 | Correct | 54 ms | 13720 KB | Output is correct |
31 | Correct | 55 ms | 15148 KB | Output is correct |
32 | Correct | 76 ms | 16828 KB | Output is correct |