이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
/*typedef __uint128_t L;
struct FastMod {
ull b, m;
FastMod(ull b) : b(b), m(ull((L(1) << 64) / b)) {}
ull reduce(ull a) {
ull q = (ull)((L(m) * a) >> 64);
ull r = a - q * b; // can be proven that 0 <= r < 2*b
return r >= b ? r - b : r;
}
};
FastMod FM(2);*/
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
cerr << " " << H;
debug_out(T...);
}
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)
#define F first
#define S second
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxn = 1e5 + 10;
ll a[maxn];
ll solve(int n){
ll L = 0, R = 1e18;
for (int i = 1; 2 * i <= n+1; i++){
MinMax(L, R, &a[i], &a[n-i+1]);
L = a[i] + 1;
R = a[n-i+1] - 1;
}
ll ans = a[2] - a[1];
for (int i = 2; i <= n; i++){
ans = max(ans, a[i] - a[i-1]);
}
return ans;
}
long long findGap(int T, int N)
{
if (T == 1){
return solve(N);
}
ll L, R; MinMax(0, 1e18, &L, &R);
ll ans = (R - L + N - 2) / (N-1);
ll k = ans;
ll ptr = L + 1;
ll lst = L;
for (int i = 1; i < N; i++){
ll mn, mx; MinMax(ptr, ptr + k - 1, &mn, &mx);
if (mn != -1){
ans = max(ans, mn - lst);
lst = mx;
}
ptr += k;
}
return ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |