QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#676715 | #5417. Chat Program | hansue | WA | 45ms | 6208kb | C++20 | 1.4kb | 2024-10-25 23:27:19 | 2024-10-25 23:27:19 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 2e5;
int n, k, m;
ll c, d;
ll a[N + 3];
int s[N + 3];
bool check(ll x){
memset(s, 0, (n + 1) * (sizeof(int)));
for(int i = 1; i <= n; i++){
// printf("i=%3d\n", i);
if(a[i] >= x){
s[1]++;
s[n + 1]--;
continue;
}
ll l, r, div;
if(a[i] + c >= x){
l = max(1, i - m + 1);
r = i;
}
else {
if(d == 0)
continue;
div = (x - c - a[i]) / d + ((x - c - a[i]) % d != 0);
// printf("x=%lld c=%lld a[i]=%lld div=%lld\n", x, c, a[i], div);
r = i - (div + 1) + 1;
l = max(1, i - m + 1);
if(r < 1)
continue;
}
// printf("l=%3d r=%3d\n", l, r);
s[l]++;
s[r + 1]--;
}
// printf("\n");
int maxc = 0;
for(int i = 1; i <= n; i++){
s[i] += s[i - 1];
maxc = max(maxc, s[i]);
}
return maxc >= k;
}
int main(){
scanf("%d%d%d%lld%lld", &n, &k, &m, &c, &d);
for(int i = 1; i <= n; i++)
scanf("%lld", &a[i]);
// check(5);
// return 0;
ll l = 1, r = 2e15, mid, ans;
while(l <= r){
// printf("%lld,%lld\n", l, r);
mid = (l + r) >> 1;
if(check(mid)){
ans = mid;
l = mid + 1;
}
else
r = mid - 1;
}
printf("%lld", ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5864kb
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: 3956kb
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: 3880kb
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: -100
Wrong Answer
time: 45ms
memory: 6208kb
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:
140723546625984
result:
wrong answer 1st numbers differ - expected: '0', found: '140723546625984'