結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー umezoumezo
提出日時 2021-11-12 22:30:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 392 ms / 3,000 ms
コード長 891 bytes
コンパイル時間 2,027 ms
コンパイル使用メモリ 207,100 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-04 09:40:53
合計ジャッジ時間 10,305 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 335 ms
6,940 KB
testcase_05 AC 311 ms
6,940 KB
testcase_06 AC 108 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 144 ms
6,944 KB
testcase_09 AC 211 ms
6,940 KB
testcase_10 AC 125 ms
6,940 KB
testcase_11 AC 96 ms
6,944 KB
testcase_12 AC 17 ms
6,940 KB
testcase_13 AC 239 ms
6,940 KB
testcase_14 AC 218 ms
6,940 KB
testcase_15 AC 388 ms
6,940 KB
testcase_16 AC 96 ms
6,944 KB
testcase_17 AC 181 ms
6,940 KB
testcase_18 AC 165 ms
6,944 KB
testcase_19 AC 118 ms
6,940 KB
testcase_20 AC 59 ms
6,944 KB
testcase_21 AC 213 ms
6,944 KB
testcase_22 AC 332 ms
6,940 KB
testcase_23 AC 388 ms
6,940 KB
testcase_24 AC 338 ms
6,944 KB
testcase_25 AC 325 ms
6,940 KB
testcase_26 AC 392 ms
6,940 KB
testcase_27 AC 329 ms
6,940 KB
testcase_28 AC 373 ms
6,940 KB
testcase_29 AC 354 ms
6,940 KB
testcase_30 AC 366 ms
6,944 KB
testcase_31 AC 369 ms
6,940 KB
testcase_32 AC 316 ms
6,944 KB
testcase_33 AC 1 ms
6,940 KB
testcase_34 AC 2 ms
6,940 KB
testcase_35 AC 2 ms
6,940 KB
testcase_36 AC 1 ms
6,940 KB
testcase_37 AC 2 ms
6,940 KB
testcase_38 AC 2 ms
6,940 KB
testcase_39 AC 2 ms
6,940 KB
testcase_40 AC 1 ms
6,940 KB
testcase_41 AC 2 ms
6,944 KB
testcase_42 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;

ll n,aa,b,x,y;
ll A[100100];
bool f(ll k){
  ll a=aa;
  vector<ll> H(n);
  rep(i,n) H[i]=A[i]-k;
  
  sort(ALL(H));
  reverse(ALL(H));
  int now=0;
  while(a>0 && now<n && H[now]>=x){
    H[now]-=x;
    a--;
    if(H[now]<x) now++;
  }
  sort(ALL(H));
  reverse(ALL(H));
  now=0;
  while(a>0 && now<n){
    H[now]-=x;
    a--;
    now++;
  }
  if(now==n){
    return true;
  }
  ll sum=0;
  rep(i,n){
    if(H[i]>0) sum+=H[i];
  }
  if(sum<=b*y) return true;
  else return false;
}

 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  cin>>n>>aa>>b>>x>>y;
  rep(i,n) cin>>A[i];
  
  ll ng=-1,ok=1e9+7;
  while(ok-ng>1){
    ll mid=(ok+ng)/2;
    if(f(mid)) ok=mid;
    else ng=mid;
  }
  cout<<ok<<endl;
  
  return 0;
}
0