이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define V vector
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;
long long findGap(int T, int N)
{
if(T == 1) {
int l = 1, r = N;
ll lb = 0, rb = 1e18;
V<ll> v(N + 1);
while(l <= r) {
ll mn, mx;
MinMax(lb, rb, &mn, &mx);
v[l] = mn, v[r] = mx;
l++, r--;
lb = mn+1, rb = mx-1;
}
ll ans = 0;
for(int i = 1; i < N; i++) ans = max(ans, v[i+1]-v[i]);
return ans;
} else {
ll s, t, ans = 0;
MinMax(0, 1e18, &s, &t);
ll p = (t - s + N - 1) / N;
ll pre = s;
for(ll i = s+1; i <= t; i+=p+1) {
ll mn, mx;
MinMax(i, i+p, &mn, &mx);
if(mn != -1) {
ans = max(ans, mn - pre);
pre = mx;
}
}
return ans;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |