結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー CleyLCleyL
提出日時 2021-12-25 11:43:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 753 ms / 3,000 ms
コード長 1,080 bytes
コンパイル時間 678 ms
コンパイル使用メモリ 77,024 KB
実行使用メモリ 5,944 KB
最終ジャッジ日時 2023-10-21 12:27:20
合計ジャッジ時間 14,332 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 492 ms
5,680 KB
testcase_05 AC 747 ms
5,944 KB
testcase_06 AC 144 ms
5,944 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 209 ms
4,808 KB
testcase_09 AC 261 ms
5,036 KB
testcase_10 AC 231 ms
4,348 KB
testcase_11 AC 140 ms
4,348 KB
testcase_12 AC 6 ms
4,348 KB
testcase_13 AC 285 ms
4,864 KB
testcase_14 AC 485 ms
5,468 KB
testcase_15 AC 429 ms
5,676 KB
testcase_16 AC 333 ms
4,348 KB
testcase_17 AC 208 ms
4,492 KB
testcase_18 AC 379 ms
4,476 KB
testcase_19 AC 55 ms
4,348 KB
testcase_20 AC 94 ms
4,348 KB
testcase_21 AC 200 ms
5,008 KB
testcase_22 AC 403 ms
5,588 KB
testcase_23 AC 454 ms
5,940 KB
testcase_24 AC 753 ms
5,940 KB
testcase_25 AC 675 ms
5,676 KB
testcase_26 AC 498 ms
5,940 KB
testcase_27 AC 728 ms
5,936 KB
testcase_28 AC 510 ms
5,940 KB
testcase_29 AC 722 ms
5,936 KB
testcase_30 AC 526 ms
5,676 KB
testcase_31 AC 563 ms
5,936 KB
testcase_32 AC 748 ms
5,944 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 2 ms
4,348 KB
testcase_36 AC 1 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 3 ms
4,348 KB
testcase_40 AC 2 ms
4,348 KB
testcase_41 AC 3 ms
4,348 KB
testcase_42 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
long long n,a,b,x,y;
vector<long long> R;
bool solve(long long ce){
    int nwa = a;
    priority_queue<long long,vector<long long>> A;
    for(int i = 0; n > i; i++){
      
        if(R[i]-ce > 0){
          A.push(R[i]-ce);
        }
    }
    while(nwa){
        if(A.size() == 0){
          return true;
        }
        auto z = A.top();A.pop();
        if(z > x){
            A.push(z-x);
        }
        nwa--;
    }
    long long size = 0;
    while(A.size()){
        auto z = A.top();A.pop();
        size+=z;
    }
    if(size > b*y){
      if(ce == 6)cout << size << " " << b*y << endl;
        return false;
    }else{
      
        return true;
    }
    

}

int main(){
  cin>>n>>a>>b>>x>>y;
  for(int i = 0; n > i; i++){
    int t;cin>>t;
    R.push_back(t);
  }
  long long mn = -1;
  long long mx = 1000000000;
  while(abs(mn-mx) > 1){
    long long ce = (mn+mx)/2;
    if(solve(ce)){
      mx = ce;
    }else{
      mn = ce;
    }
  }
  cout << mx << endl;
}
0