結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー umezoumezo
提出日時 2021-11-12 22:30:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 432 ms / 3,000 ms
コード長 891 bytes
コンパイル時間 2,308 ms
コンパイル使用メモリ 205,556 KB
実行使用メモリ 5,032 KB
最終ジャッジ日時 2023-08-17 02:29:15
合計ジャッジ時間 11,742 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 373 ms
4,908 KB
testcase_05 AC 337 ms
4,948 KB
testcase_06 AC 119 ms
4,916 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 147 ms
4,380 KB
testcase_09 AC 231 ms
4,824 KB
testcase_10 AC 141 ms
4,380 KB
testcase_11 AC 108 ms
4,376 KB
testcase_12 AC 19 ms
4,376 KB
testcase_13 AC 260 ms
4,520 KB
testcase_14 AC 238 ms
4,756 KB
testcase_15 AC 428 ms
4,952 KB
testcase_16 AC 103 ms
4,376 KB
testcase_17 AC 198 ms
4,380 KB
testcase_18 AC 180 ms
4,380 KB
testcase_19 AC 126 ms
4,384 KB
testcase_20 AC 63 ms
4,380 KB
testcase_21 AC 221 ms
4,628 KB
testcase_22 AC 358 ms
4,780 KB
testcase_23 AC 432 ms
4,952 KB
testcase_24 AC 380 ms
4,968 KB
testcase_25 AC 358 ms
5,032 KB
testcase_26 AC 412 ms
4,904 KB
testcase_27 AC 356 ms
4,940 KB
testcase_28 AC 407 ms
4,988 KB
testcase_29 AC 375 ms
4,940 KB
testcase_30 AC 400 ms
4,940 KB
testcase_31 AC 390 ms
4,904 KB
testcase_32 AC 349 ms
4,972 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 3 ms
4,380 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 2 ms
4,380 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