이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define xx first
#define yy second
#define MAXN 100010
using namespace std;
vector<int> svi;
long long findGap(int t, int n)
{
if (t==1)
{
ll minn, maxx;
MinMax(0LL, 1000000000000000000LL, &minn, &maxx);
if (n==2) { return maxx-minn; }
int i=1; int j=n-2;
ll ress=0;
while (i<=j)
{
ll staromin=minn, staromax=maxx;
MinMax(minn+1, maxx-1, &minn, &maxx);
if (j-i==1) { ress=max(ress, maxx-minn); }
ress=max(ress, max(minn-staromin, staromax-maxx));
i++; j--;
}
return ress;
}
else
{
ll minn, maxx;
MinMax(0LL, 1000000000000000000LL, &minn, &maxx);
int skok=(maxx-minn+n-2)/(n-1);
//cout<<minn<<" "<<maxx<<" "<<skok<<endl;
for (int i=minn; i<maxx; i+=skok)
{
ll a, b;
MinMax(i, min(maxx, (ll)i+skok-1), &a, &b);
//cout<<endl<<i<<" "<<min(maxx, (ll)i+skok-1)<<" "<<a<<" "<<b<<endl;
if (a==-1) { continue; }
else if (a!=b) { /*cout<<a<<" "<<b<<endl;*/ svi.pb(a); svi.pb(b); }
else { /*cout<<a<<endl;*/ svi.pb(a); }
}
ll ress=skok;
for (int i=0; i<svi.size()-1; i++) ress=max(ress, (ll)(svi[i+1]-svi[i]));
return ress;
}
}
컴파일 시 표준 에러 (stderr) 메시지
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:58:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
58 | for (int i=0; i<svi.size()-1; i++) ress=max(ress, (ll)(svi[i+1]-svi[i]));
| ~^~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |