이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<string>
#include<set>
#include<utility>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<stack>
#include"gap.h"
using namespace std;
long long findGap(int T, int N){
long long ans = 0;
if(T == 1){
vector<long long> a;
long long s = 0, t = 1000000000000000000LL;
while (true)
{
long long mn, mx;
if(a.size() == N) break;
if(s > t) break;
MinMax(s, t, &mn, &mx);
if(mn == -1) break;
if(mn < mx){
a.push_back(mn);
a.push_back(mx);
s = mn + 1;
t = mx - 1;
}
if(mn == mx){
a.push_back(mn);
break;
}
}
sort(a.begin(), a.end());
ans = 0;
for(int i=0; i<N-1; i++){
ans = max(ans, a[i+1] - a[i]);
}
}
else{
vector<long long> a;
long long ms = 0, mt = 1000000000000000000LL;
long long mn, mx;
MinMax(ms, mt, &mn, &mx);
a.push_back(mn);
a.push_back(mx);
long long s = mn + 1, t = mn + 2;
while (true)
{
if(a.size() == N) break;
MinMax(s, t, &mn, &mx);
if(mn < mx){
a.push_back(mn);
a.push_back(mx);
}
if(mn == mx){
a.push_back(mn);
}
s = t + 1;
t = s + 2;
}
sort(a.begin(), a.end());
ans = 0;
for(int i=0; i<N-1; i++){
ans = max(ans, a[i+1] - a[i]);
}
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:27:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(a.size() == N) break;
~~~~~~~~~^~~~
gap.cpp:73:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(a.size() == N) break;
~~~~~~~~~^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |