# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
159072 | 2019-10-20T13:10:13 Z | dennisstar | 화살표 그리기 (KOI18_arrowH) | C++11 | 50 ms | 5496 KB |
#include <bits/stdc++.h> #define fi first #define se second using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef long double ld; int N; vector<int> ar[100010]; int main() { scanf("%d", &N); int a, b; int i, j; for (i=0; i<N; i++) { scanf("%d %d", &a, &b); ar[b].push_back(a); } ll ans=0; for (i=1; i<=N; i++) { sort(ar[i].begin(), ar[i].end()); for (j=0; j<ar[i].size(); j++) { a=(j?ar[i][j-1]:-(1<<30)); b=(j<ar[i].size()-1?ar[i][j+1]:-(1<<30)); ans+=(ll)((a==b&&a==-(1<<30))?0:min(abs(ar[i][j]-a), abs(ar[i][j]-b))); } } printf("%lld", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Correct | 4 ms | 2680 KB | Output is correct |
3 | Correct | 4 ms | 2680 KB | Output is correct |
4 | Correct | 4 ms | 2680 KB | Output is correct |
5 | Correct | 4 ms | 2680 KB | Output is correct |
6 | Correct | 4 ms | 2680 KB | Output is correct |
7 | Correct | 4 ms | 2680 KB | Output is correct |
8 | Correct | 4 ms | 2680 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Correct | 4 ms | 2680 KB | Output is correct |
3 | Correct | 4 ms | 2680 KB | Output is correct |
4 | Correct | 4 ms | 2680 KB | Output is correct |
5 | Correct | 4 ms | 2680 KB | Output is correct |
6 | Correct | 4 ms | 2680 KB | Output is correct |
7 | Correct | 4 ms | 2680 KB | Output is correct |
8 | Correct | 4 ms | 2680 KB | Output is correct |
9 | Correct | 4 ms | 2680 KB | Output is correct |
10 | Correct | 4 ms | 2680 KB | Output is correct |
11 | Correct | 4 ms | 2680 KB | Output is correct |
12 | Correct | 4 ms | 2680 KB | Output is correct |
13 | Correct | 4 ms | 2680 KB | Output is correct |
14 | Correct | 4 ms | 2680 KB | Output is correct |
15 | Correct | 4 ms | 2680 KB | Output is correct |
16 | Correct | 5 ms | 2680 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Correct | 4 ms | 2680 KB | Output is correct |
3 | Correct | 4 ms | 2680 KB | Output is correct |
4 | Correct | 4 ms | 2680 KB | Output is correct |
5 | Correct | 4 ms | 2680 KB | Output is correct |
6 | Correct | 4 ms | 2680 KB | Output is correct |
7 | Correct | 4 ms | 2680 KB | Output is correct |
8 | Correct | 4 ms | 2680 KB | Output is correct |
9 | Correct | 4 ms | 2680 KB | Output is correct |
10 | Correct | 4 ms | 2680 KB | Output is correct |
11 | Correct | 4 ms | 2680 KB | Output is correct |
12 | Correct | 4 ms | 2680 KB | Output is correct |
13 | Correct | 4 ms | 2680 KB | Output is correct |
14 | Correct | 4 ms | 2680 KB | Output is correct |
15 | Correct | 4 ms | 2680 KB | Output is correct |
16 | Correct | 5 ms | 2680 KB | Output is correct |
17 | Correct | 7 ms | 2884 KB | Output is correct |
18 | Correct | 7 ms | 2808 KB | Output is correct |
19 | Correct | 7 ms | 2780 KB | Output is correct |
20 | Correct | 8 ms | 2936 KB | Output is correct |
21 | Correct | 7 ms | 2812 KB | Output is correct |
22 | Correct | 7 ms | 2808 KB | Output is correct |
23 | Correct | 8 ms | 2936 KB | Output is correct |
24 | Correct | 8 ms | 2928 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Correct | 4 ms | 2680 KB | Output is correct |
3 | Correct | 4 ms | 2680 KB | Output is correct |
4 | Correct | 4 ms | 2680 KB | Output is correct |
5 | Correct | 4 ms | 2680 KB | Output is correct |
6 | Correct | 4 ms | 2680 KB | Output is correct |
7 | Correct | 4 ms | 2680 KB | Output is correct |
8 | Correct | 4 ms | 2680 KB | Output is correct |
9 | Correct | 4 ms | 2680 KB | Output is correct |
10 | Correct | 4 ms | 2680 KB | Output is correct |
11 | Correct | 4 ms | 2680 KB | Output is correct |
12 | Correct | 4 ms | 2680 KB | Output is correct |
13 | Correct | 4 ms | 2680 KB | Output is correct |
14 | Correct | 4 ms | 2680 KB | Output is correct |
15 | Correct | 4 ms | 2680 KB | Output is correct |
16 | Correct | 5 ms | 2680 KB | Output is correct |
17 | Correct | 7 ms | 2884 KB | Output is correct |
18 | Correct | 7 ms | 2808 KB | Output is correct |
19 | Correct | 7 ms | 2780 KB | Output is correct |
20 | Correct | 8 ms | 2936 KB | Output is correct |
21 | Correct | 7 ms | 2812 KB | Output is correct |
22 | Correct | 7 ms | 2808 KB | Output is correct |
23 | Correct | 8 ms | 2936 KB | Output is correct |
24 | Correct | 8 ms | 2928 KB | Output is correct |
25 | Correct | 50 ms | 5496 KB | Output is correct |
26 | Correct | 38 ms | 4652 KB | Output is correct |
27 | Correct | 46 ms | 5116 KB | Output is correct |
28 | Correct | 39 ms | 4600 KB | Output is correct |
29 | Correct | 44 ms | 5056 KB | Output is correct |
30 | Correct | 38 ms | 4616 KB | Output is correct |
31 | Correct | 38 ms | 4600 KB | Output is correct |
32 | Correct | 44 ms | 5240 KB | Output is correct |