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