이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll findGap(int t, int n) {
ll l, r; MinMax(0, 1e18, &l, &r);
if (t == 1) {
ll ans = 0;
FOR(i, 1, (n+1)/2-1) {
ll x, y; MinMax(l+1, r-1, &x, &y);
ans = max({ans, r - y, x-l});
l = x, r = y;
}
return max(ans, r-l);
} else {
ll gap = (r-l-1+n-2)/(n-1), pre = l, ans = 0;
// + n-2 to ceiling to ensure its exactly n-1 groups
for (ll i = l+1; i < r-1; i += gap) {
ll x, y; MinMax(i, min(i+gap-1, r-1), &x, &y);
if (x == -1) continue;
if (pre != -1) ans = max(ans, x - pre);
pre = y;
}
return max(ans, r - pre);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |