QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#729494 | #5417. Chat Program | Calculatelove | WA | 57ms | 5456kb | C++14 | 1.1kb | 2024-11-09 17:13:24 | 2024-11-09 17:13:30 |
Judging History
answer
#include <bits/stdc++.h>
typedef long long s64;
const int N = 200100;
int n, k, m, c, d;
int a[N];
int S[N];
bool check(s64 mid) {
for (int i = 1; i <= n; i ++) S[i] = 0;
for (int i = 1; i <= n; i ++) {
if (a[i] >= mid) { S[1] ++; continue; }
int x;
if (d == 0) {
if (mid - c - a[i] < 0)
x = 0;
else
x = m;
} else {
x = (mid - c - a[i]) / d;
if (x < 0) x = 0;
}
if (x >= m) continue;
if (i - x <= 0) continue;
int l = std::max(1, i - m + 1), r = i - x;
S[l] ++, S[r + 1] --;
}
for (int i = 1; i <= n; i ++) S[i] += S[i - 1];
for (int i = 1; i <= n; i ++)
if (S[i] >= k) return 1;
return 0;
}
int main() {
scanf("%d%d%d%d%d", &n, &k, &m, &c, &d);
for (int i = 1; i <= n; i ++)
scanf("%d", &a[i]);
s64 l = 0, r = 1000000000000000000;
while (l < r) {
s64 mid = (l + r + 1) >> 1;
if (check(mid)) l = mid; else r = mid - 1;
}
printf("%lld\n", l);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3768kb
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: 0ms
memory: 3944kb
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: 0ms
memory: 3952kb
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: 52ms
memory: 5456kb
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: -100
Wrong Answer
time: 57ms
memory: 5400kb
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:
100001999999999
result:
wrong answer 1st numbers differ - expected: '100001000000000', found: '100001999999999'