QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#269947#7144. Candiesddl_VS_pigeon#WA 1ms3608kbC++171.2kb2023-11-30 12:02:232023-11-30 12:02:24

Judging History

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

  • [2023-11-30 12:02:24]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3608kb
  • [2023-11-30 12:02:23]
  • 提交

answer

#include <iostream>
#include <algorithm>
#include <functional>
#include <array>
#include <vector>
#include <queue>

using namespace std;

using ll = long long;

void solve(){
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int freeV = max(y-(x-1),0);
    y -= freeV;
    a[0] += freeV;
    auto check = [&](int exv)->ll {
        ll ret = a[0];
        priority_queue<ll,vector<ll>,greater<ll>> pq;
        pq.push(a[0]+exv);
        for(int i=1;i<n;i++){
            pq.push(a[i]);
        }
        for(int i=0;i<m;i++){
            ll v = pq.top();
            pq.pop();
            if(v==ret) ret += x;
            pq.push(v+x);
        }
        return ret;
    };
    ll baseAns = check(0);
    int l = 0;
    int r = y;
    ll ans = 0;
    while(l<=r){
        int mid = (l+r)>>1;
        ll cv = check(mid);
        if(cv<baseAns){
            r = mid-1;
        }else{
            l = mid+1;
            ans = cv;
        }
    }
    cout << ans << '\n';
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int T;
    // cin >> T;
    T = 1;
    while(T--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2 1 2 2
1 2

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3524kb

input:

10 9 4 3
19 32 11 1 3 3 3 12 17 34

output:

19

result:

wrong answer 1st numbers differ - expected: '22', found: '19'