Submission #1097119

#TimeUsernameProblemLanguageResultExecution timeMemory
1097119vjudge1Xor Sort (eJOI20_xorsort)C++17
0 / 100
1 ms344 KiB
#include "bits/stdc++.h" const signed MOD = 1e9 + 7; const signed mod = 998244353; using namespace std; #define all(x) x.begin(), x.end() #define ld long double #define ll long long #define pb push_back #define mp make_pair #define co cout << #define S second #define F first ll n, a[1000001]; bool sol(ll x) { ll t = x; vector<pair<ll, ll>> s; for (int i = 0; i < n * 2; i++) { if (a[i] <= t) { t += a[i]; while (s.size() && s.back().F <= t) { t += s.back().S; s.pop_back(); } } else { s.pb(mp(a[i], t - x + a[i])); t = x; } } return (s.empty()); } void solve() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; a[i + n] = a[i]; } ll l = 0, r = 1e13; while (l < r) { ll m = l + r >> 1; if (sol(m)) r = m; else l = m + 1; } co l; } signed main() { cin.tie(0)->sync_with_stdio(0); signed t = 1; // cin >> t; while (t--) solve(); }

Compilation message (stderr)

xorsort.cpp: In function 'void solve()':
xorsort.cpp:43:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   43 |         ll m = l + r >> 1;
      |                ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...