이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll mn,mx;
ll l,r,mid;
ll a[100005];
int h,t;
ll ans;
unsigned long long now,pre;
unsigned long long len;
long long findGap(int T, int N)
{
if (T==1) {
h=0,t=N+1;
l=0,r=1e18+1;
for (;;) {
MinMax(l,r,&mn,&mx);
a[++h]=mn,a[--t]=mx;
l=mn+1,r=mx-1;
if (h>=t-1) break;
}
for (int i=1;i<=N-1;i++) {
ll t=a[i+1]-a[i];
if (t>ans) ans=t;
}
} else {
MinMax(0,1e18+1,&mn,&mx);
now=mn;
len=1;
pre=now;
ll top=mx;
while (now+1<=top) {
ll t=top;
if (now+len<t) t=now+len;
MinMax(now+1,t,&mn,&mx);
if (mn==-1) {
now+=len;
len*=2;
} else {
ans=max(ans,mn-(ll)pre);
now=mx;
pre=mx;
len=1;
}
}
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:34:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while (now+1<=top) {
~~~~~^~~~~
gap.cpp:36:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (now+len<t) t=now+len;
~~~~~~~^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |