Submission #152314

# Submission time Handle Problem Language Result Execution time Memory
152314 2019-09-07T11:41:14 Z starwh03 None (KOI18_arrowH) C++14
100 / 100
160 ms 7000 KB
#include<bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef pair<int,int> p;
p in[110000];
vector<int> apchuk;
vector<int> dis[110000];

int main()
{
    int n;
    cin>>n;
    long long tot=0;
    for(int i=0;i<n;i++)cin>>in[i].f>>in[i].s,apchuk.push_back(in[i].s);
    sort(apchuk.begin(),apchuk.end());
    apchuk.erase(unique(apchuk.begin(),apchuk.end()),apchuk.end());
    for(int i=0;i<n;i++)
    {
        in[i].s=lower_bound(apchuk.begin(),apchuk.end(),in[i].s)-apchuk.begin();
        dis[in[i].s].push_back(in[i].f);
    }
    for(int i=0;i<apchuk.size();i++)
    {
        int m=dis[i].size()-1;
        sort(dis[i].begin(),dis[i].end());
        for(int j=1;j<m;j++)tot+=min(dis[i][j]-dis[i][j-1],dis[i][j+1]-dis[i][j]);
        tot+=m>0?dis[i][m]-dis[i][m-1]+dis[i][1]-dis[i][0]:0;
    }
    cout<<tot;
    return 0;
}

Compilation message

arrow.cpp: In function 'int main()':
arrow.cpp:23:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<apchuk.size();i++)
                 ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2936 KB Output is correct
2 Correct 5 ms 2936 KB Output is correct
3 Correct 4 ms 2936 KB Output is correct
4 Correct 4 ms 2936 KB Output is correct
5 Correct 5 ms 2936 KB Output is correct
6 Correct 4 ms 2936 KB Output is correct
7 Correct 5 ms 2936 KB Output is correct
8 Correct 4 ms 2936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2936 KB Output is correct
2 Correct 5 ms 2936 KB Output is correct
3 Correct 4 ms 2936 KB Output is correct
4 Correct 4 ms 2936 KB Output is correct
5 Correct 5 ms 2936 KB Output is correct
6 Correct 4 ms 2936 KB Output is correct
7 Correct 5 ms 2936 KB Output is correct
8 Correct 4 ms 2936 KB Output is correct
9 Correct 6 ms 2936 KB Output is correct
10 Correct 6 ms 2936 KB Output is correct
11 Correct 6 ms 2936 KB Output is correct
12 Correct 7 ms 2936 KB Output is correct
13 Correct 7 ms 2992 KB Output is correct
14 Correct 7 ms 2980 KB Output is correct
15 Correct 6 ms 2936 KB Output is correct
16 Correct 7 ms 2936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2936 KB Output is correct
2 Correct 5 ms 2936 KB Output is correct
3 Correct 4 ms 2936 KB Output is correct
4 Correct 4 ms 2936 KB Output is correct
5 Correct 5 ms 2936 KB Output is correct
6 Correct 4 ms 2936 KB Output is correct
7 Correct 5 ms 2936 KB Output is correct
8 Correct 4 ms 2936 KB Output is correct
9 Correct 6 ms 2936 KB Output is correct
10 Correct 6 ms 2936 KB Output is correct
11 Correct 6 ms 2936 KB Output is correct
12 Correct 7 ms 2936 KB Output is correct
13 Correct 7 ms 2992 KB Output is correct
14 Correct 7 ms 2980 KB Output is correct
15 Correct 6 ms 2936 KB Output is correct
16 Correct 7 ms 2936 KB Output is correct
17 Correct 18 ms 3192 KB Output is correct
18 Correct 16 ms 3192 KB Output is correct
19 Correct 15 ms 3192 KB Output is correct
20 Correct 18 ms 3324 KB Output is correct
21 Correct 15 ms 3192 KB Output is correct
22 Correct 16 ms 3192 KB Output is correct
23 Correct 16 ms 3164 KB Output is correct
24 Correct 18 ms 3192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2936 KB Output is correct
2 Correct 5 ms 2936 KB Output is correct
3 Correct 4 ms 2936 KB Output is correct
4 Correct 4 ms 2936 KB Output is correct
5 Correct 5 ms 2936 KB Output is correct
6 Correct 4 ms 2936 KB Output is correct
7 Correct 5 ms 2936 KB Output is correct
8 Correct 4 ms 2936 KB Output is correct
9 Correct 6 ms 2936 KB Output is correct
10 Correct 6 ms 2936 KB Output is correct
11 Correct 6 ms 2936 KB Output is correct
12 Correct 7 ms 2936 KB Output is correct
13 Correct 7 ms 2992 KB Output is correct
14 Correct 7 ms 2980 KB Output is correct
15 Correct 6 ms 2936 KB Output is correct
16 Correct 7 ms 2936 KB Output is correct
17 Correct 18 ms 3192 KB Output is correct
18 Correct 16 ms 3192 KB Output is correct
19 Correct 15 ms 3192 KB Output is correct
20 Correct 18 ms 3324 KB Output is correct
21 Correct 15 ms 3192 KB Output is correct
22 Correct 16 ms 3192 KB Output is correct
23 Correct 16 ms 3164 KB Output is correct
24 Correct 18 ms 3192 KB Output is correct
25 Correct 160 ms 7000 KB Output is correct
26 Correct 134 ms 5984 KB Output is correct
27 Correct 154 ms 6512 KB Output is correct
28 Correct 128 ms 5924 KB Output is correct
29 Correct 153 ms 6384 KB Output is correct
30 Correct 125 ms 5796 KB Output is correct
31 Correct 133 ms 6000 KB Output is correct
32 Correct 145 ms 6640 KB Output is correct