이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
ll findGap(int T, int n){
if(T == 1){
ll ans = 0, a, b;
MinMax(0, 1e18, &a, &b);
for(int i = 0; i < (n+1)/2-1; i++){
ll x, y;
MinMax(a+1, b-1, &x, &y);
ans = max(ans, max(x-a, b-y));
a = x, b = y;
}
if(n%2 == 0) ans = max(ans, b-a);
return ans;
}
ll ans = 0, a, b;
MinMax(0, 1e18, &a, &b);
ll k = (b-a+n-2)/(n-1);
ll prev = a;
int cnt = 0;
for(ll i = a; i <= b; i+=k){
cnt++;
ll x, y;
if(i == b) x = b, y = b;
else MinMax(i, min(i+k-1, b), &x, &y);
if(x == -1) continue;
ans = max(ans, x-prev);
prev = y;
}
assert(cnt <= n);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |