Submission #63159

# Submission time Handle Problem Language Result Execution time Memory
63159 2018-08-01T01:30:21 Z comfile None (KOI18_arrowH) C++17
100 / 100
77 ms 12812 KB
#include <bits/stdc++.h>
#define N 100010
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
vector<int> v[N];
int n;
pair<int,int> a[N];
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d%d",&a[i].first,&a[i].second);
    sort(a,a+n);
    for(int i=0;i<n;i++) v[a[i].second].pb(a[i].first);
    ll ans=0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<v[i].size();j++){
            if(!j && v[i].size()>1) ans+=(ll)(v[i][1]-v[i][0]);
            if(j==(v[i].size()-1) && v[i].size()>1) ans+=(ll)(v[i][j]-v[i][j-1]);
            if(v[i].size()>2 && j>0 && j<v[i].size()-1) ans+=(ll)min(v[i][j+1]-v[i][j],v[i][j]-v[i][j-1]);
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Compilation message

arrow.cpp: In function 'int main()':
arrow.cpp:17:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=0;j<v[i].size();j++){
                     ~^~~~~~~~~~~~
arrow.cpp:19:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(j==(v[i].size()-1) && v[i].size()>1) ans+=(ll)(v[i][j]-v[i][j-1]);
                ~^~~~~~~~~~~~~~~~~
arrow.cpp:20:41: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(v[i].size()>2 && j>0 && j<v[i].size()-1) ans+=(ll)min(v[i][j+1]-v[i][j],v[i][j]-v[i][j-1]);
                                        ~^~~~~~~~~~~~~~
arrow.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
arrow.cpp:12:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<n;i++) scanf("%d%d",&a[i].first,&a[i].second);
                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 6 ms 2796 KB Output is correct
3 Correct 6 ms 2796 KB Output is correct
4 Correct 5 ms 2816 KB Output is correct
5 Correct 6 ms 2904 KB Output is correct
6 Correct 6 ms 2904 KB Output is correct
7 Correct 4 ms 2904 KB Output is correct
8 Correct 6 ms 3008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 6 ms 2796 KB Output is correct
3 Correct 6 ms 2796 KB Output is correct
4 Correct 5 ms 2816 KB Output is correct
5 Correct 6 ms 2904 KB Output is correct
6 Correct 6 ms 2904 KB Output is correct
7 Correct 4 ms 2904 KB Output is correct
8 Correct 6 ms 3008 KB Output is correct
9 Correct 6 ms 3008 KB Output is correct
10 Correct 6 ms 3008 KB Output is correct
11 Correct 7 ms 3008 KB Output is correct
12 Correct 8 ms 3008 KB Output is correct
13 Correct 6 ms 3052 KB Output is correct
14 Correct 6 ms 3168 KB Output is correct
15 Correct 6 ms 3168 KB Output is correct
16 Correct 6 ms 3168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 6 ms 2796 KB Output is correct
3 Correct 6 ms 2796 KB Output is correct
4 Correct 5 ms 2816 KB Output is correct
5 Correct 6 ms 2904 KB Output is correct
6 Correct 6 ms 2904 KB Output is correct
7 Correct 4 ms 2904 KB Output is correct
8 Correct 6 ms 3008 KB Output is correct
9 Correct 6 ms 3008 KB Output is correct
10 Correct 6 ms 3008 KB Output is correct
11 Correct 7 ms 3008 KB Output is correct
12 Correct 8 ms 3008 KB Output is correct
13 Correct 6 ms 3052 KB Output is correct
14 Correct 6 ms 3168 KB Output is correct
15 Correct 6 ms 3168 KB Output is correct
16 Correct 6 ms 3168 KB Output is correct
17 Correct 12 ms 3376 KB Output is correct
18 Correct 11 ms 3500 KB Output is correct
19 Correct 9 ms 3744 KB Output is correct
20 Correct 11 ms 3744 KB Output is correct
21 Correct 9 ms 3884 KB Output is correct
22 Correct 10 ms 3992 KB Output is correct
23 Correct 10 ms 4104 KB Output is correct
24 Correct 12 ms 4228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 6 ms 2796 KB Output is correct
3 Correct 6 ms 2796 KB Output is correct
4 Correct 5 ms 2816 KB Output is correct
5 Correct 6 ms 2904 KB Output is correct
6 Correct 6 ms 2904 KB Output is correct
7 Correct 4 ms 2904 KB Output is correct
8 Correct 6 ms 3008 KB Output is correct
9 Correct 6 ms 3008 KB Output is correct
10 Correct 6 ms 3008 KB Output is correct
11 Correct 7 ms 3008 KB Output is correct
12 Correct 8 ms 3008 KB Output is correct
13 Correct 6 ms 3052 KB Output is correct
14 Correct 6 ms 3168 KB Output is correct
15 Correct 6 ms 3168 KB Output is correct
16 Correct 6 ms 3168 KB Output is correct
17 Correct 12 ms 3376 KB Output is correct
18 Correct 11 ms 3500 KB Output is correct
19 Correct 9 ms 3744 KB Output is correct
20 Correct 11 ms 3744 KB Output is correct
21 Correct 9 ms 3884 KB Output is correct
22 Correct 10 ms 3992 KB Output is correct
23 Correct 10 ms 4104 KB Output is correct
24 Correct 12 ms 4228 KB Output is correct
25 Correct 77 ms 7716 KB Output is correct
26 Correct 48 ms 8320 KB Output is correct
27 Correct 69 ms 10156 KB Output is correct
28 Correct 50 ms 11128 KB Output is correct
29 Correct 51 ms 12468 KB Output is correct
30 Correct 41 ms 12468 KB Output is correct
31 Correct 42 ms 12468 KB Output is correct
32 Correct 53 ms 12812 KB Output is correct