結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー gotetengoteten
提出日時 2021-11-12 22:07:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,110 bytes
コンパイル時間 1,543 ms
コンパイル使用メモリ 175,500 KB
実行使用メモリ 8,556 KB
最終ジャッジ日時 2024-05-04 08:58:37
合計ジャッジ時間 14,225 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 WA -
testcase_04 AC 519 ms
8,428 KB
testcase_05 AC 612 ms
8,556 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 92 ms
6,056 KB
testcase_09 AC 145 ms
7,908 KB
testcase_10 AC 335 ms
5,624 KB
testcase_11 WA -
testcase_12 AC 13 ms
5,376 KB
testcase_13 WA -
testcase_14 AC 389 ms
7,560 KB
testcase_15 AC 348 ms
8,544 KB
testcase_16 AC 360 ms
5,376 KB
testcase_17 AC 191 ms
5,848 KB
testcase_18 AC 403 ms
5,952 KB
testcase_19 AC 107 ms
5,828 KB
testcase_20 WA -
testcase_21 AC 225 ms
7,748 KB
testcase_22 AC 349 ms
8,056 KB
testcase_23 AC 608 ms
8,416 KB
testcase_24 AC 596 ms
8,544 KB
testcase_25 AC 613 ms
8,548 KB
testcase_26 WA -
testcase_27 AC 604 ms
8,412 KB
testcase_28 WA -
testcase_29 AC 611 ms
8,416 KB
testcase_30 AC 611 ms
8,416 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 2 ms
5,376 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 3 ms
5,376 KB
testcase_40 AC 2 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;

#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
const int mod = 1000000007;
const long long INF = 1LL << 60;
using ll = long long;

ll N,A,B,X,Y;
vector<ll> H;

bool solve(ll K){
  
  auto h=H;
  rep(i,N){
    h[i]-=K;
  }

  priority_queue<pair<ll,ll>> que;
  rep(i,N){
    que.push(make_pair(h[i],i));
  }

  rep(iter,A){
    auto Q=que.top();
    ll maxh=Q.first;
    ll i=Q.second;
    que.pop();

    h[i]-=X;
    if(h[i]<0) h[i]=0;
    que.push(make_pair(h[i],i));
  }

  ll sum=0;
  rep(i,N){
    if(h[i]>0) sum+=h[i];
  }
  return sum>B*Y;
  
}

int main()
{
  
  cin >> N >> A >> B >> X >> Y;
  H.resize(N);
  rep(i,N){
    cin >> H[i];
  }

  //[OK,NG)で考える
  ll OK=0;
  ll NG=1001001001;

  while(abs(OK-NG)>1){
    ll mid=(OK+NG)/2;
    if(solve(mid)){
      //midでtrueならOKの下界をmidにまで引き上げる
      OK=mid;
    }
    else{
      //midでfalseならNGの上界を(mid-1)に引き下げる
      NG=mid;
    }
  }
  //OKにtrueの中で最も大きい整数が
  cout << OK+1 << endl;
}
0