QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#786332 | #5417. Chat Program | 123adad | WA | 52ms | 6228kb | C++23 | 855b | 2024-11-26 21:07:58 | 2024-11-26 21:08:00 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
ios::sync_with_stdio(0),cin.tie(0);
ll n,k,m,c,d;
cin>>n>>k>>m>>c>>d;
vector<ll> a(n+1);
for(int i=1;i<=n;i++){
cin>>a[i];
}
auto check=[&](ll x)->bool{
ll res=0,cnt=0;
vector<ll> dx(n+1,0);
for(int i=1;i<=n;i++){
if(a[i]>=x){
cnt++;
continue;
}
if(a[i]+c+(m-1)*d<x){
continue;
}
ll temp=0;
if(a[i]+c>=x){
temp=0;
}else{
temp=(x-a[i]-c)/d+((x-a[i]-c)%d?1:0);
}
if(i-temp<0){
continue;
}
dx[max(1ll,i-m+1)]++;
dx[i-temp]--;
}
for(int i=1;i<=n;i++){
dx[i]+=dx[i-1];
res=max(res,cnt+dx[i]);
}
return res>=k;
};
ll l=-1,r=1e18;
while(l+1!=r){
ll mid=(l+r)>>1;
if(check(mid)) l=mid;
else r=mid;
}
cout<<l;;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3532kb
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: 3604kb
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: 3792kb
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: 46ms
memory: 6228kb
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: 52ms
memory: 6204kb
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:
100000000000000
result:
wrong answer 1st numbers differ - expected: '100001000000000', found: '100000000000000'