이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
vector<long long> vec;
long long a[100005];
long long findGap(int t, int n)
{
if (t==1)
{
long long l=1, r=1e18, ans=0;
for (int i=1; i<=n/2; i++)
{
MinMax(l, r, &a[i], &a[n-i+1]);
l=a[i]+1;
r=a[n-i+1]-1;
}
if (n&1)
MinMax(l, r, &a[n/2+1], &a[n/2+1]);
for (int i=2; i<=n; i++)
ans=max(ans, a[i]-a[i-1]);
return ans;
}
else
{
long long l, r, num, ans=0;
MinMax(1, 1e18, &l, &r);
vec.push_back(l);
vec.push_back(r);
num=(r-l-1)/(n-1)+1;
for (long long i=l+1; i<r; i+=num+1)
{
long long j=min(r-1, i+num), resL, resR;
MinMax(i, j, &resL, &resR);
if (resL!=-1)
vec.push_back(resL);
if (resR!=resL)
vec.push_back(resR);
}
sort(vec.begin(), vec.end());
for (int i=1; i<vec.size(); i++)
ans=max(ans, vec[i]-vec[i-1]);
return ans;
}
}
컴파일 시 표준 에러 (stderr) 메시지
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:40:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | for (int i=1; i<vec.size(); i++)
| ~^~~~~~~~~~~| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |