# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
234850 | 2020-05-26T01:20:24 Z | jhnah917 | 화살표 그리기 (KOI18_arrowH) | C++14 | 41 ms | 5624 KB |
#include <bits/stdc++.h> #define x first #define y second #define all(v) v.begin(), v.end() using namespace std; typedef long long ll; typedef pair<ll, ll> p; int n; vector<int> v[101010]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i=0; i<n; i++){ int a, b; cin >> a >> b; v[b].push_back(a); } ll ans = 0; for(int i=0; i<101010; i++){ sort(all(v[i])); if(v[i].size() <= 1) continue; for(int j=0; j<v[i].size(); j++){ if(j == 0) ans += v[i][1] - v[i][j]; else if(j == v[i].size() - 1) ans += v[i][j] - v[i][j-1]; else ans += min(v[i][j] - v[i][j-1], v[i][j+1] - v[i][j]); } } cout << ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2688 KB | Output is correct |
2 | Correct | 6 ms | 2688 KB | Output is correct |
3 | Correct | 6 ms | 2688 KB | Output is correct |
4 | Correct | 6 ms | 2688 KB | Output is correct |
5 | Correct | 6 ms | 2688 KB | Output is correct |
6 | Correct | 6 ms | 2688 KB | Output is correct |
7 | Correct | 6 ms | 2688 KB | Output is correct |
8 | Correct | 6 ms | 2688 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2688 KB | Output is correct |
2 | Correct | 6 ms | 2688 KB | Output is correct |
3 | Correct | 6 ms | 2688 KB | Output is correct |
4 | Correct | 6 ms | 2688 KB | Output is correct |
5 | Correct | 6 ms | 2688 KB | Output is correct |
6 | Correct | 6 ms | 2688 KB | Output is correct |
7 | Correct | 6 ms | 2688 KB | Output is correct |
8 | Correct | 6 ms | 2688 KB | Output is correct |
9 | Correct | 6 ms | 2688 KB | Output is correct |
10 | Correct | 6 ms | 2688 KB | Output is correct |
11 | Correct | 6 ms | 2688 KB | Output is correct |
12 | Correct | 6 ms | 2688 KB | Output is correct |
13 | Correct | 7 ms | 2688 KB | Output is correct |
14 | Correct | 6 ms | 2688 KB | Output is correct |
15 | Correct | 7 ms | 2816 KB | Output is correct |
16 | Correct | 6 ms | 2688 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2688 KB | Output is correct |
2 | Correct | 6 ms | 2688 KB | Output is correct |
3 | Correct | 6 ms | 2688 KB | Output is correct |
4 | Correct | 6 ms | 2688 KB | Output is correct |
5 | Correct | 6 ms | 2688 KB | Output is correct |
6 | Correct | 6 ms | 2688 KB | Output is correct |
7 | Correct | 6 ms | 2688 KB | Output is correct |
8 | Correct | 6 ms | 2688 KB | Output is correct |
9 | Correct | 6 ms | 2688 KB | Output is correct |
10 | Correct | 6 ms | 2688 KB | Output is correct |
11 | Correct | 6 ms | 2688 KB | Output is correct |
12 | Correct | 6 ms | 2688 KB | Output is correct |
13 | Correct | 7 ms | 2688 KB | Output is correct |
14 | Correct | 6 ms | 2688 KB | Output is correct |
15 | Correct | 7 ms | 2816 KB | Output is correct |
16 | Correct | 6 ms | 2688 KB | Output is correct |
17 | Correct | 9 ms | 2944 KB | Output is correct |
18 | Correct | 10 ms | 2944 KB | Output is correct |
19 | Correct | 8 ms | 2944 KB | Output is correct |
20 | Correct | 9 ms | 2944 KB | Output is correct |
21 | Correct | 8 ms | 2944 KB | Output is correct |
22 | Correct | 8 ms | 2944 KB | Output is correct |
23 | Correct | 9 ms | 2944 KB | Output is correct |
24 | Correct | 9 ms | 2944 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 2688 KB | Output is correct |
2 | Correct | 6 ms | 2688 KB | Output is correct |
3 | Correct | 6 ms | 2688 KB | Output is correct |
4 | Correct | 6 ms | 2688 KB | Output is correct |
5 | Correct | 6 ms | 2688 KB | Output is correct |
6 | Correct | 6 ms | 2688 KB | Output is correct |
7 | Correct | 6 ms | 2688 KB | Output is correct |
8 | Correct | 6 ms | 2688 KB | Output is correct |
9 | Correct | 6 ms | 2688 KB | Output is correct |
10 | Correct | 6 ms | 2688 KB | Output is correct |
11 | Correct | 6 ms | 2688 KB | Output is correct |
12 | Correct | 6 ms | 2688 KB | Output is correct |
13 | Correct | 7 ms | 2688 KB | Output is correct |
14 | Correct | 6 ms | 2688 KB | Output is correct |
15 | Correct | 7 ms | 2816 KB | Output is correct |
16 | Correct | 6 ms | 2688 KB | Output is correct |
17 | Correct | 9 ms | 2944 KB | Output is correct |
18 | Correct | 10 ms | 2944 KB | Output is correct |
19 | Correct | 8 ms | 2944 KB | Output is correct |
20 | Correct | 9 ms | 2944 KB | Output is correct |
21 | Correct | 8 ms | 2944 KB | Output is correct |
22 | Correct | 8 ms | 2944 KB | Output is correct |
23 | Correct | 9 ms | 2944 KB | Output is correct |
24 | Correct | 9 ms | 2944 KB | Output is correct |
25 | Correct | 41 ms | 5624 KB | Output is correct |
26 | Correct | 34 ms | 4708 KB | Output is correct |
27 | Correct | 39 ms | 5112 KB | Output is correct |
28 | Correct | 33 ms | 4736 KB | Output is correct |
29 | Correct | 40 ms | 4984 KB | Output is correct |
30 | Correct | 32 ms | 4600 KB | Output is correct |
31 | Correct | 33 ms | 4728 KB | Output is correct |
32 | Correct | 39 ms | 5240 KB | Output is correct |