QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#685082 | #5417. Chat Program | Vegetog | WA | 58ms | 8324kb | C++20 | 1.7kb | 2024-10-28 17:31:00 | 2024-10-28 17:31:02 |
Judging History
answer
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#include "_my_utils.h"
#endif
#define int long long
using namespace std;
using ll = long long;
using PII = std::pair<int, int>;
constexpr ll INF = 2E18 + 10;
constexpr int N = 2E5 + 10;
int n, k, m, c, d;
int a[N];
int b[N], pr[N];
bool check(int x) {
for (int i = 1; i <= n; i++) {
a[i] = b[i];
pr[i] = 0;
}
for (int i = 1; i <= n; i++) {
if (a[i] >= x) {
pr[1]++;
pr[n + 1]--;
} else if (a[i] + c + d * (min(i, m) - 1) >= x) {
if (d == 0) {
pr[max(1LL, i - m + 1)]++;
pr[i + 1]--;
continue;
}
pr[max(1LL, i - m + 1)]++;
int mx = a[i] + c + d * (min(i, m) - 1);
int cnt = (mx - (x - 1) + d - 1) / d;
pr[min(n + 1, max(1LL, i - m + 1) + cnt - 1 + 1)]--;
}
}
int t = 0;
for (int i = 1; i + m - 1 <= n; i++) {
t += pr[i];
if (t >= k) {
return 1;
}
}
return 0;
}
void SINGLE_TEST() {
cin >> n >> k >> m >> c >> d;
for (int i = 1; i <= n; i++) {
cin >> a[i];
b[i] = a[i];
}
int l = 0, r = INF;
while (l < r) {
int mid = (l + r + 1) / 2;
if (check(mid)) {
l = mid;
} else {
r = mid - 1;
}
}
cout << l << "\n";
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int SAMPLES = 1;
// cin >> SAMPLES;
for (int CUR = 1; CUR <= SAMPLES; CUR++) {
SINGLE_TEST();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5692kb
input:
6 4 3 1 2 1 1 4 5 1 4
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: 0
Accepted
time: 1ms
memory: 5632kb
input:
7 3 2 4 0 1 9 1 9 8 1 0
output:
9
result:
ok 1 number(s): "9"
Test #3:
score: 0
Accepted
time: 1ms
memory: 5692kb
input:
8 3 5 0 0 2 0 2 2 1 2 1 8
output:
2
result:
ok 1 number(s): "2"
Test #4:
score: 0
Accepted
time: 49ms
memory: 8272kb
input:
200000 200000 100000 0 1000000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
output:
0
result:
ok 1 number(s): "0"
Test #5:
score: 0
Accepted
time: 40ms
memory: 8324kb
input:
200000 1 100000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100000000...
output:
100001000000000
result:
ok 1 number(s): "100001000000000"
Test #6:
score: 0
Accepted
time: 37ms
memory: 8276kb
input:
200000 1 200000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100000000...
output:
200001000000000
result:
ok 1 number(s): "200001000000000"
Test #7:
score: -100
Wrong Answer
time: 58ms
memory: 8288kb
input:
200000 24420 17993 881138881 700368758 231187558 519018952 260661004 740633836 931672020 155904999 647179942 13217847 779799803 382810661 242588977 708308843 309853544 225488875 389115097 588643904 644409212 704920939 231829287 39891424 881158891 341251089 486868469 808002305 629160633 317239613 771...
output:
964475746
result:
wrong answer 1st numbers differ - expected: '964474978', found: '964475746'