QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#794209 | #5417. Chat Program | proking | TL | 20ms | 5132kb | C++14 | 2.5kb | 2024-11-30 12:54:46 | 2024-11-30 12:54:46 |
Judging History
answer
#include <bits/stdc++.h>
#define F(i, a, b) for (int i = a; i <= b; i ++)
#define G(i, a, b) for (int i = a; i >= b; i --)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define mx(a, b) ((a) = max(a, b))
#define mn(a, b) ((a) = min(a, b))
#define get getchar()
#define putc putchar
#define outarr(a, L, R) { prllf(#a"[%d..%d]", L, R); F(i, L, R) W(a[i]), putc(' ') ; putc('\n'); }
#define out1(x) { printf(#x" = "), W(x), putc('\n'); }
#define out2(x, y) { printf(#x" = "), W(x), printf(" "#y" = "), W(y), putc('\n'); }
#define out3(x, y, z) { printf(#x" = "), W(x), printf(" "#y" = "), W(y), printf(" "#z" = "), W(z), putc('\n'); }
#define out4(x, y, z, w) { printf(#x" = %d", x); printf(" "#y" = %d", y); printf(" "#z" = %d", z), printf(" "#w" = %d", w), putc('\n'); }
#define Assert(x, y) { if (!(x)) { printf("Wrong %d", y); exit(0); } }
#define mem(a, b) memset(a, b, sizeof a)
#define mec(a, b) memcpy(a, b, sizeof a)
#define pi pair<int, int>
#define V vector <int>
#define ll long long
#define get getchar()
#define pb push_back
#define putc putchar
#define pb push_back
#define db double
#define fi first
#define se second
using namespace std;
template <typename Int>
void R(Int &x) {
char c = get; x = 0; Int t = 1;
for (; !isdigit(c); c = get) t = (c == '-' ? -1 : t);
for (; isdigit(c); x = (x << 3) + (x << 1) + c - '0', c = get); x *= t;
}
template <typename Int>
void W(Int x) {
if (x < 0) { putc('-'); x = - x; }
if (x > 9) W(x / 10); putc(x % 10 + '0');
}
using namespace std;
const int N = 2e5 + 10;
int n, k, m, c, d, a[N], f[N];
bool ok(int p) {
// out1(p);
F(i, 1, n) f[i] = 0;
int Max = 0, cnt = 0;
F(i, 1, n) {
// out2(a[i], p);
if (a[i] >= p) {
cnt ++;
continue;
}
// out1(d);
if (d == 0) {
if (c + a[i] >= p) {
if (i + m - 1 <= n)
f[i] ++, f[i + 1] --;
}
continue;
}
int w = a[i] + c >= p ? 0 : ((p - c - a[i] - 1) / d + 1);
// if (p == 6) {
// out4(p - c - a[i] - 1, d, w, a[i]);
// out2(max(1, i - m + 1), max(1, i - w + 1));
// putc('\n');
// }
if (w <= m)
f[max(1, i - m + 1)] ++, f[max(1, i - w + 1)] --;
}
F(i, 1, n) f[i] += f[i - 1], mx(Max, cnt + f[i]);
// out2(cnt, Max);
return Max >= k;
}
int main() {
// freopen("data.in","r",stdin);
R(n), R(k), R(m), R(c), R(d);
F(i, 1, n) R(a[i]);
int l = 0, r = 2e9, ans = -1;
while (l <= r) {
int md = l + r >> 1;
if (ok(md))
ans = md, l = md + 1;
else
r = md - 1;
}
W(ans);
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3580kb
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: 3636kb
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: 3640kb
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: 20ms
memory: 5132kb
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
Time Limit Exceeded
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...