QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#745500 | #5417. Chat Program | HHS | WA | 0ms | 3744kb | C++14 | 1.1kb | 2024-11-14 10:21:57 | 2024-11-14 10:21:58 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,k,c,d;
void solve()
{
cin>>n>>k>>m>>c>>d;
vector<ll>a(n+10);
for(ll i=1;i<=n;i++)
cin>>a[i];
ll l=0,r=2e18;
vector<ll>cha(n+10);
while(l<=r)
{
ll mid=(l+r)/2;
//cout<<mid<<endl;
ll cnt=0;
for(ll i=1;i<=n;i++)
if(a[i]>=mid)cnt++,cha[i]=0;
if(cnt>=k)
{
l=mid+1;
continue;
}
for(ll i=1;i<=n;i++)
{
if(a[i]>=mid)continue;
if(d==0)
{
if(a[i]+c>=mid)
{
cha[i]++;
ll s=min(n,i+m-1);
cha[s+1]--;
}
}
else{
ll x=(mid-a[i]-c+d-1)/d;
x=max(x,(ll)0);
if(x<=m-1)
{
cha[i]++;
ll s=min(n,i+m-x-1);
cha[s+1]--;
}
}
}
for(ll i=1;i<=n;i++)
cha[i]+=cha[i-1];
ll flag=0;
for(ll i=1;i<=n;i++)
{
if(cha[i]+cnt>=k)
{
flag=1;
break;
}
}
if(flag)
{
l=mid+1;
}
else {
r=mid-1;
}
}
cout<<r<<endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll t=1;
while(t--)
{
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3744kb
input:
6 4 3 1 2 1 1 4 5 1 4
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3528kb
input:
7 3 2 4 0 1 9 1 9 8 1 0
output:
11
result:
wrong answer 1st numbers differ - expected: '9', found: '11'