結果

問題 No.1736 Princess vs. Dragoness
ユーザー ぷらぷら
提出日時 2021-11-12 21:26:17
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 770 bytes
コンパイル時間 1,976 ms
コンパイル使用メモリ 197,720 KB
最終ジャッジ日時 2025-01-25 15:44:19
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int N,A,B,X,Y;
    cin >> N >> A >> B >> X >> Y;
    priority_queue<int>que;
    for(int i = 0; i < N; i++) {
        int H;
        cin >> H;
        que.push(H);
    }
    int p = 0;
    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);
            }
        }
    }
    cout << ((que.empty())?"Yes":"No") << endl;
}
0