結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー monnumonnu
提出日時 2021-11-12 21:43:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 267 ms / 3,000 ms
コード長 1,189 bytes
コンパイル時間 4,051 ms
コンパイル使用メモリ 231,472 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-04 07:56:22
合計ジャッジ時間 8,760 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 247 ms
5,376 KB
testcase_05 AC 267 ms
5,376 KB
testcase_06 AC 43 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 151 ms
5,376 KB
testcase_09 AC 208 ms
5,376 KB
testcase_10 AC 81 ms
5,376 KB
testcase_11 AC 15 ms
5,376 KB
testcase_12 AC 9 ms
5,376 KB
testcase_13 AC 29 ms
5,376 KB
testcase_14 AC 187 ms
5,376 KB
testcase_15 AC 250 ms
5,376 KB
testcase_16 AC 72 ms
5,376 KB
testcase_17 AC 127 ms
5,376 KB
testcase_18 AC 106 ms
5,376 KB
testcase_19 AC 73 ms
5,376 KB
testcase_20 AC 12 ms
5,376 KB
testcase_21 AC 171 ms
5,376 KB
testcase_22 AC 230 ms
5,376 KB
testcase_23 AC 266 ms
5,376 KB
testcase_24 AC 267 ms
5,376 KB
testcase_25 AC 240 ms
5,376 KB
testcase_26 AC 47 ms
5,376 KB
testcase_27 AC 258 ms
5,376 KB
testcase_28 AC 48 ms
5,376 KB
testcase_29 AC 265 ms
5,376 KB
testcase_30 AC 250 ms
5,376 KB
testcase_31 AC 46 ms
5,376 KB
testcase_32 AC 46 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 3 ms
5,376 KB
testcase_40 AC 1 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 2 ms
5,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