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;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpi;
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
#define pb push_back
#define rsz resize
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)
#define fi first
#define se second
long long findGap(int T, int N)
{
ll s=0;
ll t=1e18;
vector<ll>v;
ll a,b;
MinMax(s,t,&a,&b);
ll lef=a;
ll rig=b;
v.pb(a);
v.pb(b);
ll len =(b-1 - (a-1)+1)/(N-1);
s=a+1;
t=a+len;
F0R(i,N-1)
{
if(i==N-2)t=rig-1;
MinMax(s,t,&a,&b);
v.pb(a);
v.pb(b);
s+=len;
t+=len;
}
sort(all(v));
ll rec=-1e9;
F0R(i,sz(v)-1)
{
rec=max(rec,v[i+1]-v[i]);
}
return rec;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:30:5: warning: unused variable 'lef' [-Wunused-variable]
30 | ll lef=a;
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |