Submission #140584

# Submission time Handle Problem Language Result Execution time Memory
140584 2019-08-03T15:57:36 Z khrbuddy03 None (KOI18_arrowH) C++14
100 / 100
48 ms 6008 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int inf = 1e5 + 9;

vector<ll> arr[inf];

int main()  {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        int x, y; cin >> x >> y;
        arr[y].push_back(x);
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        sort(arr[i].begin(), arr[i].end());
        if (arr[i].size() == 1 || arr[i].size() == 0) continue;
        else {
            for (int j = 1; j < arr[i].size() - 1; j++) {
                ans += min(arr[i][j] - arr[i][j - 1], arr[i][j + 1] - arr[i][j]);
            }
            ans += (arr[i][arr[i].size() - 1] - arr[i][arr[i].size() - 2]) + (arr[i][1] - arr[i][0]);
        }
    }
    cout << ans << '\n';
}

Compilation message

arrow.cpp: In function 'int main()':
arrow.cpp:24:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int j = 1; j < arr[i].size() - 1; j++) {
                             ~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2808 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 2684 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 2684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2808 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 2684 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 2684 KB Output is correct
9 Correct 5 ms 2808 KB Output is correct
10 Correct 5 ms 2808 KB Output is correct
11 Correct 5 ms 2808 KB Output is correct
12 Correct 5 ms 2680 KB Output is correct
13 Correct 5 ms 2808 KB Output is correct
14 Correct 5 ms 2808 KB Output is correct
15 Correct 5 ms 2808 KB Output is correct
16 Correct 5 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2808 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 2684 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 2684 KB Output is correct
9 Correct 5 ms 2808 KB Output is correct
10 Correct 5 ms 2808 KB Output is correct
11 Correct 5 ms 2808 KB Output is correct
12 Correct 5 ms 2680 KB Output is correct
13 Correct 5 ms 2808 KB Output is correct
14 Correct 5 ms 2808 KB Output is correct
15 Correct 5 ms 2808 KB Output is correct
16 Correct 5 ms 2680 KB Output is correct
17 Correct 8 ms 2936 KB Output is correct
18 Correct 7 ms 2936 KB Output is correct
19 Correct 8 ms 2936 KB Output is correct
20 Correct 8 ms 2936 KB Output is correct
21 Correct 8 ms 2936 KB Output is correct
22 Correct 7 ms 2936 KB Output is correct
23 Correct 7 ms 2936 KB Output is correct
24 Correct 8 ms 3064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2808 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 2684 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 2684 KB Output is correct
9 Correct 5 ms 2808 KB Output is correct
10 Correct 5 ms 2808 KB Output is correct
11 Correct 5 ms 2808 KB Output is correct
12 Correct 5 ms 2680 KB Output is correct
13 Correct 5 ms 2808 KB Output is correct
14 Correct 5 ms 2808 KB Output is correct
15 Correct 5 ms 2808 KB Output is correct
16 Correct 5 ms 2680 KB Output is correct
17 Correct 8 ms 2936 KB Output is correct
18 Correct 7 ms 2936 KB Output is correct
19 Correct 8 ms 2936 KB Output is correct
20 Correct 8 ms 2936 KB Output is correct
21 Correct 8 ms 2936 KB Output is correct
22 Correct 7 ms 2936 KB Output is correct
23 Correct 7 ms 2936 KB Output is correct
24 Correct 8 ms 3064 KB Output is correct
25 Correct 46 ms 6008 KB Output is correct
26 Correct 39 ms 5324 KB Output is correct
27 Correct 42 ms 5624 KB Output is correct
28 Correct 34 ms 5112 KB Output is correct
29 Correct 42 ms 5624 KB Output is correct
30 Correct 37 ms 5112 KB Output is correct
31 Correct 36 ms 5112 KB Output is correct
32 Correct 48 ms 5624 KB Output is correct