이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
/*
void MinMax(long long x,long long y,long long* a,long long* b)
{
cout << x << ' ' << y << endl;
int aa,bb;
cin >> aa >> bb;
*a = aa,*b = bb;
}
*/
vector<long long> a,b;
long long findGap(int t,int n)
{
long long mn,mx;
MinMax(0,1e18,&mn,&mx);
a.push_back(mn),b.push_back(mx);
int l = 1,r = n-2;
while(l<=r)
{
MinMax(mn+1,mx-1,&mn,&mx);
a.push_back(mn),b.push_back(mx);
l++,r--;
}
long long ans = 0;
for(int i = 0;i < a.size()-1;i++) ans = max(ans,a[i+1]-a[i]);
for(int i = 0;i < b.size()-1;i++) ans = max(ans,b[i]-b[i+1]);
ans = max(ans,abs(a.back()-b.back()));
return ans;
}
/*
int main()
{
int x;
cin >> x;
cout << findGap(0,x);
}*/
컴파일 시 표준 에러 (stderr) 메시지
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:34:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0;i < a.size()-1;i++) ans = max(ans,a[i+1]-a[i]);
~~^~~~~~~~~~~~
gap.cpp:35:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0;i < b.size()-1;i++) ans = max(ans,b[i]-b[i+1]);
~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |