This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
mt19937_64 gen(rand() ^ (rand() << 16));
typedef long long ll;
typedef pair<ll,ll> ii;
ll NN,TT,maior;
ll findGap(int T,int N){
TT = T;
NN = N;
ll ini = 0,fim = (ll)1e18;
if(T == 1){
vector<ll> vetor;
for(ll qtd = N;qtd >= 1;qtd -= 2){
ll copia1,copia2;
MinMax(ini,fim,&copia1,&copia2);
vetor.push_back(copia1);
vetor.push_back(copia2);
ini = copia1;
fim = copia2;
ini++,fim--;
}
sort(vetor.begin(),vetor.end());
for(ll i = 0;i+1<vetor.size();i++) maior = max(maior, vetor[i+1] - vetor[i] );
return maior;
}
vector<ll> vetor;
ll lo,hi;
MinMax(ini,fim,&lo,&hi);
ini = lo;
fim = hi;
ll gap = (ll)ceil(hi - lo)/double(N-1);
for(ll left = ini;left<=fim;left += gap + 1){
ll right = left + gap;
MinMax(left,right,&lo,&hi);
vetor.push_back(lo);
vetor.push_back(hi);
}
sort(vetor.begin(),vetor.end());
for(ll i = 1;i<vetor.size();i++) maior = max(maior, vetor[i] - vetor[i-1] );
return maior;
}
Compilation message (stderr)
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:24:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(ll i = 0;i+1<vetor.size();i++) maior = max(maior, vetor[i+1] - vetor[i] );
^
gap.cpp:40:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(ll i = 1;i<vetor.size();i++) maior = max(maior, vetor[i] - vetor[i-1] );
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |