QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#740201 | #5417. Chat Program | NULL_SF | WA | 40ms | 8384kb | C++17 | 922b | 2024-11-13 03:38:31 | 2024-11-13 03:38:32 |
Judging History
answer
#include <iostream>
#define int long long
using namespace std;
int a[200003],suf[200003],big[200003];
int n,k,m,c,d;
bool check(int mid)
{
for(int i=0;i<=n+1;i++){
suf[i]=0;
}
big[0]=0;
for(int i=1;i<=n;i++){
int del;
if(d) del=min(m,max(0ll,(mid-(a[i]+c)+d-1)/d));
else del=(mid<=a[i]+c)?0:m;
suf[min(n-m+1,max(1ll,i-m+1))]++;
suf[min(n-m+2,max(1ll,i-del+1))]--;
big[i]=big[i-1]+(a[i]>=mid);
}
for(int i=1;i<=n+1;i++){
suf[i]+=suf[i-1];
}
int cnt=0;
for(int i=1;i<=n-m+1;i++){
cnt=max(cnt,big[i-1]+suf[i]+(big[n]-big[i+m-1]));
}
return cnt>=k;
}
signed main()
{
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>n>>k>>m>>c>>d;
for(int i=1;i<=n;i++){
cin>>a[i];
}
int l=0,r=1e9;
while(l<r)
{
int mid=(l+r+1)/2;
if(check(mid)) l=mid;
else r=mid-1;
}
cout<<l<<'\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5672kb
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: 5668kb
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: 7628kb
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: 32ms
memory: 8368kb
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: 40ms
memory: 8384kb
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:
1000000000
result:
wrong answer 1st numbers differ - expected: '100001000000000', found: '1000000000'