이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long llo;
#define mp make_pair
#define a first
#define b second
#define pb push_back
#include "gap.h"
/*void MinMax(llo aa,llo bb,llo &cc,llo &dd){
cout<<aa<<" "<<bb<<endl;
llo x,y;
cin>>x>>y;
cc=x;
dd=y;
}*/
llo findGap(int t,int n){
if(t==2){
llo low,high;
MinMax(0,1e18,&low,&high);
// cout<<0<<" "<<(llo)1e18<<endl;
// cin>>low>>high;
llo di=(high-low)/((llo)(n-1));
if((high-low)%(n-1)>0){
di+=1;
}
vector<llo> ans;
ans.pb(low);
ans.pb(high);
for(llo i=low+1;i<=high;i+=di){
llo ss,tt;
MinMax(i,i+di-1,&ss,&tt);
// cout<<i<<" "<<i+di-1<<endl;
// cin>>ss>>tt;
if(ss==-1 or tt==-1){
continue;
}
ans.pb(ss);
ans.pb(tt);
}
llo ans2=0;
sort(ans.begin(),ans.end());
for(llo i=0;i<ans.size()-1;i++){
ans2=max(ans2,ans[i+1]-ans[i]);
}
return ans2;
}
else{
llo mi=0;
llo lo=1e18;
llo aa[n];
for(int i=0;i<(n+1)/2;i++){
llo ss,tt;
MinMax(mi,lo,&ss,&tt);
mi=ss+1;
lo=tt-1;
aa[i]=ss;
aa[n-i-1]=tt;
}
llo ans=0;
for(int i=0;i<n-1;i++){
ans=max(ans,aa[i+1]-aa[i]);
}
return ans;
}
}
/*int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout<<findGap(2,4)<<endl;
return 0;
}*/
컴파일 시 표준 에러 (stderr) 메시지
gap.cpp: In function 'llo findGap(int, int)':
gap.cpp:44:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(llo i=0;i<ans.size()-1;i++){
~^~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |