QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#673558 | #5417. Chat Program | cabbagea | WA | 790ms | 20836kb | C++17 | 1.5kb | 2024-10-24 23:46:14 | 2024-10-24 23:46:14 |
Judging History
answer
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
const int N=1e6+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(b[i]>=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(b[i]>=0) s.insert(b[i]);
}
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=1e18;
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: 7872kb
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: 7576kb
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: 7616kb
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: 790ms
memory: 20836kb
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: 0
Accepted
time: 75ms
memory: 18568kb
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:
100001000000000
result:
ok 1 number(s): "100001000000000"
Test #6:
score: 0
Accepted
time: 67ms
memory: 19356kb
input:
200000 1 200000 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:
200001000000000
result:
ok 1 number(s): "200001000000000"
Test #7:
score: -100
Wrong Answer
time: 347ms
memory: 16624kb
input:
200000 24420 17993 881138881 700368758 231187558 519018952 260661004 740633836 931672020 155904999 647179942 13217847 779799803 382810661 242588977 708308843 309853544 225488875 389115097 588643904 644409212 704920939 231829287 39891424 881158891 341251089 486868469 808002305 629160633 317239613 771...
output:
964183791
result:
wrong answer 1st numbers differ - expected: '964474978', found: '964183791'