이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
// vector<long long> li;
// void MinMax(long long a, long long b, long long *c, long long *d){
// vector<long long> ar;
// for(int i = 0; i<li.size(); i++){
// if(li[i]>=a && li[i]<=b){
// ar.push_back(li[i]);
// }
// }
// if(ar.size()==0){
// *c = -1;
// *d = -1;
// }
// else{
// *c = ar[0];
// *d = ar[ar.size()-1];
// }
// }
long long findGap(int T, int N)
{
long long maxval = 1000000000000000000LL;
long long mn, mx;
MinMax(1,maxval,&mn,&mx);
cout << mn << " " << mx << endl;
long long s = mn;
long long e = mx;
if(N==1){
return e-s-1LL;
}
long long ans = (e-s)/((long long)N-1LL)-1LL;
if((e-s)%((long long)N-1LL)!=0){
ans++;
}
long long last = s;
long long check = ans+1LL;
vector<long long> all;
all.push_back(s);
for(long long i = s+1LL; i<e; i+=check){
long long r = min(e-1LL,i+check-1LL);
MinMax(i,r,&mn,&mx);
if(mn!=-1){
all.push_back(mn);
all.push_back(mx);
}
}
all.push_back(e);
for(int i = 1; i<all.size(); i++){
ans = max(ans,all[i]-all[i-1]);
}
return ans;
}
// int main(){
// li.push_back(2);
// li.push_back(3);
// li.push_back(6);
// li.push_back(8);
// cout << findGap(0,4) << endl;
// }
컴파일 시 표준 에러 (stderr) 메시지
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:49:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 1; i<all.size(); i++){
^
gap.cpp:36:15: warning: unused variable 'last' [-Wunused-variable]
long long last = s;
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |