QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#686380#5417. Chat Programucup-team3474WA 679ms24952kbC++201.6kb2024-10-29 11:57:042024-10-29 11:57:04

Judging History

你现在查看的是最新测评结果

  • [2024-10-29 11:57:04]
  • 评测
  • 测评结果:WA
  • 用时:679ms
  • 内存:24952kb
  • [2024-10-29 11:57:04]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1919810;
typedef long long ll;
typedef pair<ll,ll> PII;
ll n,m,k;
ll a[N],b[N];
char s[N];
ll c,d;
ll ss[N];


bool check(ll mid){
    for(int i=1;i<=n;i++) b[i]=a[i]-mid;
    for(int i=1;i<=n;i++){
        if(b[i]>=0) ss[i]=1;
        else ss[i]=0;
        ss[i]+=ss[i-1];
    }
    ll ad=0;
    for(int i=1;i<=n;i++){
        b[i]+=ad;
        ad+=d;
    }
    // for(int i=1;i<=n;i++) cout<<b[i]<<" ";
    // cout<<endl;
    priority_queue<PII,vector<PII>,greater<PII>> q;
    ll minus=-c;
    ll mx=0;
    // cout<<ss[n]<<endl;
    for(int i=1;i<=m;i++) q.push({b[i],i});
    ll cnt=m,cnt2=0;
    
    for(int i=1;i+m-1<=n;i++){
        while(q.size()&&(q.top().first-minus)<0){
            if(q.top().second<i) cnt2++;
            q.pop();
        }
        // cout<<cnt<<" "<<cnt2<<endl;
        ll tot=q.size()-cnt2;
        tot+=(ss[n]-(ss[i+m-1]-ss[i-1]));
        // cout<<(ss[i+m-1]-s[i-1])<<endl;
        // cout<<i<<" "<<se.size()<<" "<<tot<<endl;
        // if(!se.count({b[i],i})&&b[i]+c>=0) tot++;
        mx=max(mx,tot);
        // cnt2++;
        if(b[i]-minus>=0) cnt2++;
        // if(se.count({b[i],i})) se.erase(se.find({b[i],i}));
        q.push({b[i+m],i+m});
        // cnt++;
        minus+=d;
    }
    // cout<<mid<<" "<<mx<<" "<<k<<endl;
    return mx>=k;
}

int main(){
    cin>>n>>k>>m;
    cin>>c>>d;
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    // check(9);
    ll l=0,r=1e15;
    while(l<r){
        ll mid=l+r+1>>1;
        if(check(mid)) l=mid;
        else r=mid-1;
    }
    cout<<l<<endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 9956kb

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: 9772kb

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: 10016kb

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: 363ms
memory: 18188kb

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: 416ms
memory: 17580kb

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: 679ms
memory: 24952kb

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: 615ms
memory: 17808kb

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'