Submission #152772

#TimeUsernameProblemLanguageResultExecution timeMemory
152772mhy908Gap (APIO16_gap)C++14
30 / 100
61 ms2288 KiB
#include "gap.h"
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#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;
    int num=n;
    while(fr<=re&&num){
        MinMax(fr, re, &st, &fin);
        vc.pb(st);
        num--;
        if(st!=fin){
            vc.pb(fin);
            num--;
        }
        fr=st+1;
        re=fin-1;
    }
    sort(vc.begin(), vc.end());
    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)
{
    return 0;
}
LL findGap(int T, int N)
{
	if(T==1)return subt1(N);
	return subt2(N);
}

Compilation message (stderr)

gap.cpp: In function 'LL subt1(int)':
gap.cpp:30:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i<vc.size()-1; i++){
                  ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...