結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー monnumonnu
提出日時 2021-11-12 21:43:07
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 290 ms / 3,000 ms
コード長 1,189 bytes
コンパイル時間 4,341 ms
コンパイル使用メモリ 230,604 KB
実行使用メモリ 4,808 KB
最終ジャッジ日時 2023-08-17 00:36:43
合計ジャッジ時間 10,204 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 263 ms
4,808 KB
testcase_05 AC 288 ms
4,672 KB
testcase_06 AC 45 ms
4,708 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 159 ms
4,384 KB
testcase_09 AC 217 ms
4,408 KB
testcase_10 AC 86 ms
4,376 KB
testcase_11 AC 15 ms
4,376 KB
testcase_12 AC 10 ms
4,376 KB
testcase_13 AC 31 ms
4,380 KB
testcase_14 AC 205 ms
4,376 KB
testcase_15 AC 272 ms
4,616 KB
testcase_16 AC 75 ms
4,380 KB
testcase_17 AC 135 ms
4,376 KB
testcase_18 AC 113 ms
4,380 KB
testcase_19 AC 76 ms
4,376 KB
testcase_20 AC 12 ms
4,376 KB
testcase_21 AC 179 ms
4,416 KB
testcase_22 AC 241 ms
4,488 KB
testcase_23 AC 280 ms
4,668 KB
testcase_24 AC 290 ms
4,680 KB
testcase_25 AC 259 ms
4,760 KB
testcase_26 AC 48 ms
4,680 KB
testcase_27 AC 277 ms
4,712 KB
testcase_28 AC 48 ms
4,616 KB
testcase_29 AC 277 ms
4,632 KB
testcase_30 AC 268 ms
4,628 KB
testcase_31 AC 48 ms
4,668 KB
testcase_32 AC 48 ms
4,616 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 3 ms
4,376 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 3 ms
4,376 KB
testcase_42 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll=long long;
using Graph=vector<vector<pair<int,ll>>>;
#define INF 1000000000000000000
#define MOD 998244353
#define MAX 200000

int main(){
  int N;
  ll A,B,X,Y;
  cin>>N>>A>>B>>X>>Y;
  vector<ll> H(N);
  for(int i=0;i<N;i++){
    cin>>H[i];
  }

  {
    ll x=0;
    vector<ll> h(N);
    for(int i=0;i<N;i++){
      h[i]=max<ll>(0,H[i]-x);
    }
    ll a=A;
    for(int i=0;i<N;i++){
      ll cnt=min<ll>(h[i]/X,a);
      a-=cnt;
      h[i]-=cnt*X;
    }
    sort(h.begin(),h.end());
    ll sum=0;
    for(int i=0;i<N-(int)a;i++){
      sum+=h[i];
    }
    if(sum<=B*Y){
      cout<<0<<'\n';
      return 0;
    }
  }

  ll left=0;
  ll right=1000000000;
  while(left+1<right){
    ll x=(left+right)/2;
    vector<ll> h(N);
    for(int i=0;i<N;i++){
      h[i]=max<ll>(0,H[i]-x);
    }
    ll a=A;
    for(int i=0;i<N;i++){
      ll cnt=min<ll>(h[i]/X,a);
      a-=cnt;
      h[i]-=cnt*X;
    }
    sort(h.begin(),h.end());
    ll sum=0;
    for(int i=0;i<N-(int)a;i++){
      sum+=h[i];
    }
    if(sum<=B*Y){
      right=x;
    }else{
      left=x;
    }
  }
  cout<<right<<'\n';
}
0