Submission #152775

# Submission time Handle Problem Language Result Execution time Memory
152775 2019-09-09T12:51:48 Z mhy908 Gap (APIO16_gap) C++14
100 / 100
85 ms 3364 KB
#include "gap.h"
#include <bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(), x.end()
#define llinf 8987654321987654321
#define inf 1987654321
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
vector<LL> vc;
LL subt1(int n)
{
    LL fr=0, re=1e18, st, fin;
    while(fr<=re&&n){
        MinMax(fr, re, &st, &fin);
        vc.pb(st);
        n--;
        if(st!=fin){
            vc.pb(fin);
            n--;
        }
        fr=st+1;
        re=fin-1;
    }
    sort(all(vc));
    LL ans=0;
    for(int i=0; i<vc.size()-1; i++){
        ans=max(ans, vc[i+1]-vc[i]);
    }
    return ans;
}
LL subt2(int n)
{
    LL minn, maxx;
    MinMax(0, 1e18, &minn, &maxx);
    LL t=(maxx-minn)/(n-1);
    for(int i=1; ; i++){
        LL temp1, temp2;
        LL a=minn+t*(i-1)+i-1, b=min(a+t, maxx);
        MinMax(a, b, &temp1, &temp2);
        vc.pb(temp1);
        vc.pb(temp2);
        if(b>=maxx)break;
    }
    LL ans=0;
    sort(all(vc));
    for(int i=0; i<vc.size()-1; i++){
        ans=max(ans, vc[i+1]-vc[i]);
    }
    return ans;
}
LL findGap(int T, int N)
{
	if(T==1)return subt1(N);
	return subt2(N);
}

Compilation message

gap.cpp: In function 'LL subt1(int)':
gap.cpp:28:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i<vc.size()-1; i++){
                  ~^~~~~~~~~~~~
gap.cpp: In function 'LL subt2(int)':
gap.cpp:48:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i<vc.size()-1; i++){
                  ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 128 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 376 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 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 16 ms 900 KB Output is correct
17 Correct 16 ms 888 KB Output is correct
18 Correct 16 ms 888 KB Output is correct
19 Correct 16 ms 888 KB Output is correct
20 Correct 13 ms 892 KB Output is correct
21 Correct 60 ms 2288 KB Output is correct
22 Correct 61 ms 2288 KB Output is correct
23 Correct 61 ms 2288 KB Output is correct
24 Correct 63 ms 2284 KB Output is correct
25 Correct 54 ms 2292 KB Output is correct
26 Correct 61 ms 2288 KB Output is correct
27 Correct 61 ms 2288 KB Output is correct
28 Correct 61 ms 2288 KB Output is correct
29 Correct 60 ms 2288 KB Output is correct
30 Correct 46 ms 2288 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 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 2 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 376 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 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 348 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 22 ms 1140 KB Output is correct
17 Correct 22 ms 1140 KB Output is correct
18 Correct 22 ms 1268 KB Output is correct
19 Correct 22 ms 1268 KB Output is correct
20 Correct 11 ms 1268 KB Output is correct
21 Correct 84 ms 3356 KB Output is correct
22 Correct 83 ms 3308 KB Output is correct
23 Correct 83 ms 3280 KB Output is correct
24 Correct 84 ms 3308 KB Output is correct
25 Correct 77 ms 3364 KB Output is correct
26 Correct 85 ms 3316 KB Output is correct
27 Correct 84 ms 3304 KB Output is correct
28 Correct 83 ms 3280 KB Output is correct
29 Correct 83 ms 3304 KB Output is correct
30 Correct 46 ms 3308 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct