Submission #140835

# Submission time Handle Problem Language Result Execution time Memory
140835 2019-08-05T14:20:08 Z Autoratch Gap (APIO16_gap) C++14
100 / 100
105 ms 3564 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;

vector<long long> a;

long long findGap(int t,int n)
{
    long long mn,mx,ans = 0;

    MinMax(0,1e18,&mn,&mx);

    if(t==1)
    {
        a.push_back(mn),a.push_back(mx);
        int l = 1,r = n-2;
        while(l<=r)
        {
            MinMax(mn+1,mx-1,&mn,&mx);
            a.push_back(mn),a.push_back(mx);
            l++,r--;
        }
    }        
    else
    {
        long long each = (mx-mn+n-2)/(n-1);
        ans = each;
        for(long long x = mn;x <= mx;x+=each+1)
        {
            long long xa,xb;
            MinMax(x,x+each,&xa,&xb);
            a.push_back(xa),a.push_back(xb);
        }
    }

    sort(a.begin(),a.end());

    for(int i = 0;i < a.size()-1;i++) ans = max(ans,a[i+1]-a[i]);

    return ans;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:39:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i < a.size()-1;i++) ans = max(ans,a[i+1]-a[i]);
                   ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 380 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 3 ms 504 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 17 ms 1016 KB Output is correct
17 Correct 17 ms 1016 KB Output is correct
18 Correct 17 ms 1016 KB Output is correct
19 Correct 17 ms 1016 KB Output is correct
20 Correct 13 ms 1016 KB Output is correct
21 Correct 63 ms 2412 KB Output is correct
22 Correct 64 ms 2416 KB Output is correct
23 Correct 64 ms 2416 KB Output is correct
24 Correct 105 ms 2416 KB Output is correct
25 Correct 54 ms 2416 KB Output is correct
26 Correct 64 ms 2308 KB Output is correct
27 Correct 64 ms 2412 KB Output is correct
28 Correct 63 ms 2416 KB Output is correct
29 Correct 62 ms 2372 KB Output is correct
30 Correct 49 ms 2416 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 360 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 3 ms 504 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 22 ms 1268 KB Output is correct
17 Correct 23 ms 1268 KB Output is correct
18 Correct 22 ms 1396 KB Output is correct
19 Correct 22 ms 1396 KB Output is correct
20 Correct 11 ms 1268 KB Output is correct
21 Correct 86 ms 3480 KB Output is correct
22 Correct 86 ms 3564 KB Output is correct
23 Correct 86 ms 3440 KB Output is correct
24 Correct 88 ms 3504 KB Output is correct
25 Correct 77 ms 3436 KB Output is correct
26 Correct 86 ms 3516 KB Output is correct
27 Correct 86 ms 3564 KB Output is correct
28 Correct 86 ms 3560 KB Output is correct
29 Correct 86 ms 3564 KB Output is correct
30 Correct 42 ms 3560 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct