이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define pb push_back
#define all(a) a.begin(), a.end()
const ll INF=1e18;
ll findGap(int t, int n) {
if(t==2) {
ll mi, ma;
MinMax(0, INF, &mi, &ma);
ll x=(ma-mi+n-2)/(n-1), ans=x;
ll lst=mi;
for(ll i=mi; i<=ma; i+=x+1) {
ll a, b;
MinMax(i, i+x, &a, &b);
if(a==-1) continue;
ans=max(ans, a-lst);
lst=b;
}
return ans;
}
vector<ll>A, B;
ll mi=0, ma=INF;
rep(i, (n+1)/2) {
ll a, b;
MinMax(mi, ma, &a, &b);
if(a==-1) break;
A.pb(a);
B.pb(b);
mi=a+1;
ma=b-1;
}
reverse(all(B));
for(auto i : B) A.pb(i);
ll ans=0;
rep(i, A.size()-1) ans=max(ans, A[i+1]-A[i]);
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:5:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
5 | #define rep(a, b) for(int a = 0; a < (b); ++a)
| ^
gap.cpp:38:9: note: in expansion of macro 'rep'
38 | rep(i, A.size()-1) ans=max(ans, A[i+1]-A[i]);
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |