이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include <vector>
#include <algorithm>
using namespace std;
typedef long long lint;
typedef pair<lint, lint> pi;
pi query(lint s, lint e){
pi ret;
MinMax(s, e, &ret.first, &ret.second);
return ret;
}
long long findGap(int T, int N)
{
vector<lint> a;
lint ret = 0;
if(T == 1){
lint s = 0, e = 2e18;
while(N >= 1){
auto t = query(s, e);
a.push_back(t.first);
a.push_back(t.second);
s = t.first + 1, e = t.second - 1;
N -= 2;
}
}
else{
pi q = query(0, 2e18);
lint triv = (q.second - q.first + N - 2) / (N - 1);
ret = triv;
for(lint p = q.first; p <= q.second; p += triv + 1){
auto t = query(p, p + triv);
a.push_back(t.first);
a.push_back(t.second);
}
}
sort(a.begin(), a.end());
for(int i=0; i<a.size()-1; i++){
ret = max(ret, a[i+1] - a[i]);
}
return ret;
}
컴파일 시 표준 에러 (stderr) 메시지
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:39:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<a.size()-1; i++){
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |