結果
| 問題 | 
                            No.1739 Princess vs. Dragoness (& AoE)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             ぷら
                         | 
                    
| 提出日時 | 2021-11-12 21:31:08 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,172 bytes | 
| コンパイル時間 | 2,342 ms | 
| コンパイル使用メモリ | 197,852 KB | 
| 最終ジャッジ日時 | 2025-01-25 15:52:33 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 26 WA * 14 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,X,Y,a,b;
    cin >> N >> a >> b >> X >> Y;
    vector<int>H(N);
    for(int i = 0; i < N; i++) {
        cin >> H[i];
    }
    int l = 0,r = 1001001001;
    while (l+1 < r) {
        int mid = (l+r)/2;
        int p = 0;
        int A = a,B = b;
        priority_queue<int>que;
        for(int i = 0; i < N; i++) {
            if(H[i] > mid) {
                que.push(H[i]-mid);
            }
        }
        while (!que.empty() && (A || B || p)) {
            int x = que.top();
            que.pop();
            if(A) {
                A--;
                x = max(0,x-X);
                if(x) {
                    que.push(x);
                }
            }
            else {
                if(p == 0) {
                    p = Y;
                    B--;
                }
                int D = min(p,x);
                x -= D;
                p -= D;
                if(x) {
                    que.push(x);
                }
            }
        }
        if(que.empty()) {
            r = mid;
        }
        else {
            l = mid;
        }
    }
    cout << r << endl;
}
            
            
            
        
            
ぷら