# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1097119 | vjudge1 | Xor Sort (eJOI20_xorsort) | C++17 | 1 ms | 344 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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();
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |