QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#253455 | #4571. Even Split | LaStataleBlue# | WA | 0ms | 3752kb | C++20 | 2.2kb | 2023-11-17 00:39:23 | 2023-11-17 00:39:24 |
Judging History
answer
#pragma ide diagnostic ignored "misc-no-recursion"
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef double db;
#define TESTCASE 0
#define LOCAL_INTERACTOR 0
static constexpr int INF = 1e9;
static ll find_min(int N, const vector<ll> &A) {
ll l = 1, r = 1e10;
while (r - l > 1) {
ll m = (l + r) / 2;
bool ok = true;
ll x = 0;
for (int i = 0; i < N; i++) {
if (x > A[i]) ok = false;
x = max(x + m, A[i] + 1);
}
if (ok) {
l = m;
} else {
r = m;
}
}
return l;
}
static vector<ll> find_max(int N, const vector<ll> &A, ll mi) {
vector<pair<ll, ll>> I(N + 1);
auto check = [&](ll ma) {
I[0] = {mi, ma};
for (int i = 0; i < N; i++) {
I[i].first = max(I[i].first, A[i] + 1);
I[i].second = min(I[i].second, A[i + 1]);
if (I[i].first > I[i].second) return false;
I[i + 1] = {I[i].first + mi, I[i].second + ma};
}
if (I[N - 1].second < A[N]) return false;
return true;
};
ll l = mi, r = 1e10;
while (r - l > 1) {
ll ma = (l + r) / 2;
if (!check(ma)) {
l = ma;
} else {
r = ma;
}
}
assert(check(l + 1));
vector<ll> res(N + 1);
for (ll i = N - 1, x = 1e10; i >= 0; i--) {
x = min(x - mi, I[i].second);
res[i + 1] = x;
}
return res;
}
static void solve([[maybe_unused]] int tc) {
ll L;
int N;
cin >> L >> N;
vector<ll> A(N + 1);
for (int i = 0; i < N; i++) {
cin >> A[i];
}
A[N] = L;
ll mi = find_min(N, A);
auto res = find_max(N, A, mi);
for (int i = 0; i < N; i++) {
cout << res[i] << ' ' << res[i + 1] << '\n';
}
}
int main() {
ios::sync_with_stdio(false);
if (const char *f = getenv("REDIRECT_STDOUT"); f) {
freopen(f, "w", stdout);
}
int T = 1;
#if TESTCASE
cin >> T;
#endif
for (int t = 1; t <= T; t++) {
solve(t);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3616kb
input:
6 3 1 3 5
output:
0 2 2 4 4 6
result:
ok Minimal imbalance is 0
Test #2:
score: 0
Accepted
time: 0ms
memory: 3752kb
input:
10 2 1 2
output:
0 2 2 10
result:
ok Minimal imbalance is 6
Test #3:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
100 10 14 26 29 31 34 42 44 48 49 68
output:
0 25 25 28 28 31 31 34 34 40 40 43 43 46 46 49 49 68 68 100
result:
ok Minimal imbalance is 29
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3476kb
input:
100 10 3 42 45 58 69 73 75 78 84 88
output:
0 22 22 44 44 58 58 66 66 70 70 74 74 78 78 84 84 88 88 100
result:
wrong answer Jury found better solution (j=17 vs p=18)