QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#673582 | #5417. Chat Program | cabbagea | WA | 945ms | 14468kb | C++17 | 1.6kb | 2024-10-25 00:33:33 | 2024-10-25 00:33:33 |
Judging History
answer
#pragma Gcc optimisze(2)
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
const int N=2e5+10;
int n,m;
int a[N]; int b[N];
int k; int c,d;
int pre[N],post[N];
int check(int mid){
for(int i=1;i<=n;i++) b[i]=a[i]-mid;
for(int i=1;i<=n;i++)
{
pre[i]=pre[i-1];
if(b[i]>=0) pre[i]++;
}
post[n+1]=0;
for(int i=n;i>=1;i--)
{
post[i]=post[i+1];
if(b[i]>=0) post[i]++;
}
multiset<int> s;
for(int i=1;i<=n;i++)
{
b[i]+=c+(i-1)*d;
if(b[i]>=0&&i<=m) s.insert(b[i]);
}
int res=0; int j=1;
for(int i=1;i<=n;i++)
{
int r=i+m-1;
if(r>n) break;
int temp=pre[i-1]+post[r+1]+(int)s.size();
res=max(res,temp);
if(a[i]-mid+c>=0)
//if(s.find(b[i])!=s.end())
s.erase(s.find(b[i]));
while(!s.empty())
{
int temp=*s.begin();
if(temp-j*d<0) s.erase(s.begin());
else break;
}
j++;
if(a[r+1]-mid+c+(m-1)*d>=0) s.insert(b[r+1]);
}
if(res>=k) return 1;
return 0;
}
void solve() {
cin>>n>>k>>m>>c>>d;;
for(int i=1;i<=n;i++) cin>>a[i];
int l=0; int r=1e14;
while(l<r)
{
int mid=(l+r+1)>>1;
if(check(mid)) l=mid;
else r=mid-1;
}
cout<<l<<endl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t = 1;
//cin >> t;
while (t--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5580kb
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: 5536kb
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: 7928kb
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: 945ms
memory: 14468kb
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: 218ms
memory: 12184kb
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'