이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
long long findGap(int t, int n){
if(t == 1){
ll l = 0 , r = INF , ansl , ansr , res = 0;
vector<ll> ans;
for(int i = 0 ; i < (n + 1) / 2 ; i++){
MinMax(l , r , &ansl , &ansr);
ans.push_back(ansl);
ans.push_back(ansr);
l = ansl + 1;
r = ansr - 1;
}
sort(ans.begin() , ans.end());
for(int i = 0 ; i + 1 < ans.size() ; i++){
res = max(res , ans[i + 1] - ans[i]);
}
return res;
}
ll l , r , len , x;
MinMax(0 , INF , &l , &r);
len = r - l; x = (len + n - 2) / (n - 1);
vector<ll> ans = {l , r};
for(int i = 0 ; i < n - 1 ; i++){
ll ql = l + i * x , qr = l + (i + 1) * x;
ll ansl , ansr;
MinMax(ql , qr - 1 , &ansl , &ansr);
if(ansl == -1) continue;
ans.push_back(ansl);
ans.push_back(ansr);
}
sort(ans.begin() , ans.end());
ll res = 0;
for(int i = 0 ; i + 1 < ans.size() ; i++){
res = max(res , ans[i + 1] - ans[i]);
}
//cout << len << endl;
return res;
}
컴파일 시 표준 에러 (stderr) 메시지
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:22:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | for(int i = 0 ; i + 1 < ans.size() ; i++){
| ~~~~~~^~~~~~~~~~~~
gap.cpp:41:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for(int i = 0 ; i + 1 < ans.size() ; i++){
| ~~~~~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |