이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "gap.h"
#define startt ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
using namespace std;
#define vint vector<int>
#define all(v) v.begin(), v.end()
#define MOD 1000000007
#define MOD2 998244353
#define MX 1000000000
#define MXL 1000000000000000000
#define PI (ld)2*acos(0.0)
#define pb push_back
#define sc second
#define fr first
//#define int long long
#define endl '\n'
#define ld long double
#define NO cout << "NO" << endl
#define YES cout << "YES" << endl
long long findGap(int T, int N)
{
if(T == 1)
{
long long mn, mx;
long long ask1 = 0, ask2 = 1e18;
vector<long long> a(N);
for(int i = 0; i < N; i++)
{
a[i] = -1;
}
long long nowi = 0, nowi2 = N-1;
while(true)
{
MinMax(ask1, ask2, &mn, &mx);
if(mn == -1 && mx == -1)
{
break;
}
if(mn == mx)
{
a[nowi] = mn;
break;
}
a[nowi] = mn;
nowi++;
a[nowi2] = mx;
nowi2--;
ask1 = mn+1;
ask2 = mx-1;
}
long long ans = 0;
for(int i = 0; i < N-1; i++)
{
assert(a[i] != -1);
ans = max(ans, a[i+1]-a[i]);
}
return ans;
}
else
{
long long mn, mx;
MinMax(0, 1e18, &mn, &mx);
long long size = mx-mn-1;
long long nowmin = mn+1, last = mn;
long long ans = size/(N-1);
for(int i = 0; i < N-1; i++)
{
long long nowmax = nowmin+size/(N-1)-1;
MinMax(nowmin, nowmax, &mn, &mx);
if(mn != -1)
{
ans = max(ans, mn-last);
last = mx;
}
nowmin = nowmax+1;
}
return ans;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |