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