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<bits/stdc++.h>
#include "gap.h"
using namespace std;
#define all(v) v.begin(), v.end()
typedef long long ll;
long long findGap(int T, int N){
return 1/0;
if(T==1){
vector<ll>v;
ll a=-1, b=1e18+1, c, d;
for(int i=0;i<N;i+=2){
if(a+1>b-1){
return 1/0;
}
MinMax(a+1, b-1, &c, &d);
if(c==-1)
return 1/0;
v.push_back(c);
v.push_back(d);
a=c;
b=d;
}
sort(all(v));
ll ans=0;
for(int i=1;i<v.size();++i)
ans=max(ans, v[i]-v[i-1]);
return ans;
}
ll a, b;
MinMax(0, 1e18, &a, &b);
ll c=(b-a+N-2)/(N-1);
ll ans=c;
vector<ll>v;
ll d, e;
for(int i=1;i<N;++i){
MinMax(a+(i-1)*c+1, a+i*c, &d, &e);
if(d!=-1){
v.push_back(d);
v.push_back(e);
}
}
v.push_back(a);
sort(all(v));
for(int i=1;i<v.size();++i)
ans=max(ans, v[i]-v[i-1]);
return ans;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:8:10: warning: division by zero [-Wdiv-by-zero]
8 | return 1/0;
| ~^~
gap.cpp:14:13: warning: division by zero [-Wdiv-by-zero]
14 | return 1/0;
| ~^~
gap.cpp:18:13: warning: division by zero [-Wdiv-by-zero]
18 | return 1/0;
| ~^~
gap.cpp:26:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | for(int i=1;i<v.size();++i)
| ~^~~~~~~~~
gap.cpp:45:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | for(int i=1;i<v.size();++i)
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |