結果
問題 |
No.1739 Princess vs. Dragoness (& AoE)
|
ユーザー |
![]() |
提出日時 | 2021-11-12 23:51:19 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 279 ms / 3,000 ms |
コード長 | 957 bytes |
コンパイル時間 | 1,826 ms |
コンパイル使用メモリ | 197,312 KB |
最終ジャッジ日時 | 2025-01-25 17:34:58 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define ALL(v) (v).begin(),(v).end() using ll=long long int; const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12; template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;} template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;} int main(){ int n,a,b,x,y; cin>>n>>a>>b>>x>>y; vector<int> h(n); rep(i,0,n)cin>>h[i]; int L=-1,R=inf; while(R-L>1){ int mid=(L+R)>>1; vector<int> H(n); rep(i,0,n)H[i]=max(0,h[i]-mid); int cnt=0; rep(i,0,n){ int add=max(0,min(a-cnt,H[i]/x)); H[i]-=add*x; cnt+=add; } sort(ALL(H)); ll sum=0; rep(i,0,n-(a-cnt))sum+=H[i]; if(sum<=ll(b)*y)R=mid; else L=mid; } cout<<R<<'\n'; return 0; }