Submission #1130670

#TimeUsernameProblemLanguageResultExecution timeMemory
1130670OI_AccountGap (APIO16_gap)C++20
30 / 100
43 ms1944 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 100'000; const ll INF = 1'000'000'000'000'000'000; ll n, t, a[N + 10]; void readInput(int x, int y) { t = x; n = y; } pair<ll, ll> ask(ll s, ll t) { ll a, b; MinMax(s, t, &a, &b); return {a, b}; } ll calcMax() { ll mx = 0; for (int i = 1; i < n; i++) mx = max(mx, a[i + 1] - a[i]); return mx; } ll solve1() { ll x = 0, y = INF; for (int i = 1, j = n; i <= j; i++, j--) { pair<ll, ll> p = ask(x, y); x = p.first; y = p.second; a[i] = x; a[j] = y; x++; y--; //cout << i << ' ' << j << ": " << x << ' ' << y << endl; } return calcMax(); } ll solve() { if (t) return solve1(); return 0; } long long findGap(int T, int N) { readInput(T, N); return solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...