結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー se1ka2
提出日時 2021-11-12 21:37:09
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 769 ms / 3,000 ms
コード長 782 bytes
コンパイル時間 601 ms
コンパイル使用メモリ 75,672 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-25 17:26:16
合計ジャッジ時間 13,993 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;

int main()
{
    int n, a, b;
    ll x, y;
    cin >> n >> a >> b >> x >> y;
    ll h[100005];
    for(int i = 0; i < n; i++) cin >> h[i];
    ll left = -1, right = 1000000000;
    while(right - left > 1){
        ll mid = (right + left) / 2;
        priority_queue<ll> que;
        for(int i = 0; i < n; i++) que.push(max(0ll, h[i] - mid));
        for(int i = 0; i < a; i++){
            ll u = que.top();
            que.pop();
            u = max(0ll, u - x);
            que.push(u);
        }
        ll s = 0;
        while(que.size()){
            s += que.top();
            que.pop();
        }
        if(s <= b * y) right = mid;
        else left = mid;
    }
    cout << right << endl;
}
0