Submission #126798

# Submission time Handle Problem Language Result Execution time Memory
126798 2019-07-08T12:15:43 Z arnold518 None (KOI18_arrowH) C++14
100 / 100
51 ms 5496 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5;

int N;
vector<int> V[MAXN+10];
ll ans;

int main()
{
    int i, j;

    scanf("%d", &N);
    for(i=1; i<=N; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        V[y].push_back(x);
    }
    for(i=1; i<=N; i++) sort(V[i].begin(), V[i].end());

    for(i=1; i<=N; i++)
    {
        if(V[i].size()<=1) continue;
        ans+=V[i][1]-V[i][0];
        ans+=V[i][V[i].size()-1]-V[i][V[i].size()-2];
        for(j=1; j+1<V[i].size(); j++) ans+=min(V[i][j+1]-V[i][j], V[i][j]-V[i][j-1]);
    }
    printf("%lld", ans);
}

Compilation message

arrow.cpp: In function 'int main()':
arrow.cpp:32:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(j=1; j+1<V[i].size(); j++) ans+=min(V[i][j+1]-V[i][j], V[i][j]-V[i][j-1]);
                  ~~~^~~~~~~~~~~~
arrow.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
arrow.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &x, &y);
         ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2552 KB Output is correct
3 Correct 4 ms 2552 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 2808 KB Output is correct
7 Correct 4 ms 2680 KB Output is correct
8 Correct 4 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2552 KB Output is correct
3 Correct 4 ms 2552 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 2808 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 2652 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
11 Correct 5 ms 2680 KB Output is correct
12 Correct 5 ms 2716 KB Output is correct
13 Correct 5 ms 2676 KB Output is correct
14 Correct 5 ms 2680 KB Output is correct
15 Correct 5 ms 2680 KB Output is correct
16 Correct 5 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2552 KB Output is correct
3 Correct 4 ms 2552 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 2808 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 2652 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
11 Correct 5 ms 2680 KB Output is correct
12 Correct 5 ms 2716 KB Output is correct
13 Correct 5 ms 2676 KB Output is correct
14 Correct 5 ms 2680 KB Output is correct
15 Correct 5 ms 2680 KB Output is correct
16 Correct 5 ms 2680 KB Output is correct
17 Correct 9 ms 2936 KB Output is correct
18 Correct 8 ms 2908 KB Output is correct
19 Correct 8 ms 2808 KB Output is correct
20 Correct 8 ms 2936 KB Output is correct
21 Correct 7 ms 2808 KB Output is correct
22 Correct 7 ms 2808 KB Output is correct
23 Correct 7 ms 2908 KB Output is correct
24 Correct 8 ms 2936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2552 KB Output is correct
3 Correct 4 ms 2552 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 2808 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 2652 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
11 Correct 5 ms 2680 KB Output is correct
12 Correct 5 ms 2716 KB Output is correct
13 Correct 5 ms 2676 KB Output is correct
14 Correct 5 ms 2680 KB Output is correct
15 Correct 5 ms 2680 KB Output is correct
16 Correct 5 ms 2680 KB Output is correct
17 Correct 9 ms 2936 KB Output is correct
18 Correct 8 ms 2908 KB Output is correct
19 Correct 8 ms 2808 KB Output is correct
20 Correct 8 ms 2936 KB Output is correct
21 Correct 7 ms 2808 KB Output is correct
22 Correct 7 ms 2808 KB Output is correct
23 Correct 7 ms 2908 KB Output is correct
24 Correct 8 ms 2936 KB Output is correct
25 Correct 51 ms 5496 KB Output is correct
26 Correct 37 ms 4600 KB Output is correct
27 Correct 49 ms 5116 KB Output is correct
28 Correct 38 ms 4600 KB Output is correct
29 Correct 45 ms 4984 KB Output is correct
30 Correct 38 ms 4600 KB Output is correct
31 Correct 38 ms 4620 KB Output is correct
32 Correct 48 ms 5240 KB Output is correct