이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include <iostream>
#include <climits>
using namespace std;
const int nmax=100005;
long long v[nmax];
long long mx,st,dr,act,len,oldlen,inf,sup;
int n,i;
long long findGap(int T, int N)
{
n=N;
if(T==1)
{
mx=0;
v[0]=-1;v[n+1]=1LL*1e18+1;
for(i=1;i<=n/2;i++)
{
MinMax(v[i-1]+1,v[n-i+2]-1,&v[i],&v[n-i+1]);
}
if((n&1))
{
MinMax(v[n/2]+1,v[n/2+2]-1,&v[(n+1)/2],&sup);
}
for(i=1;i<n;i++)
mx=max(mx,v[i+1]-v[i]);
return mx;
}
act=-1;len=1;oldlen=1;
bool bun=1;
MinMax(0,1LL*1e18,&inf,&sup);
long long nn=n,ans=0;
long long def=(sup-inf)/(nn-1);
if((sup-inf)%(nn-1))
def++;
act=inf;
for(long long i=1;i<=n-1&&i<=LLONG_MAX/def;i++)
{
bool ok=1;
while(ok&&i*def<=LLONG_MAX-act&&act+1LL*(i-1)*def<=sup)
{
ok=0;
if(act!=-1)oldlen=len;
MinMax(act+1,act+1LL*i*def,&st,&dr);
if(dr!=-1)
{
ans=max(st-act,ans);
act=dr;
ok=1;
}
}
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:29:10: warning: unused variable 'bun' [-Wunused-variable]
bool bun=1;
^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |