結果
問題 |
No.3281 Pacific White-sided Dolphin vs Monster
|
ユーザー |
|
提出日時 | 2025-09-26 22:18:32 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 376 ms / 2,000 ms |
コード長 | 891 bytes |
コンパイル時間 | 2,949 ms |
コンパイル使用メモリ | 281,008 KB |
実行使用メモリ | 12,800 KB |
最終ジャッジ日時 | 2025-09-26 22:18:44 |
合計ジャッジ時間 | 9,474 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 50 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; ll powll (ll a,ll n){ if(60<n)return 2e18; ll res = 1; for(ll i = 0;i<n;i++)res*=a; return res; } int main(){ ll n; cin >> n; multiset<ll> h; for(ll i = 0;i<n;i++){ ll v; cin >> v; h.insert(v); } auto solve = [&](ll x)-> bool { multiset<ll> hp(h.begin(),h.end()); while(hp.size()){ x--; if(x<0)return false; ll atk = powll(2,x); ll M = *hp.rbegin(); hp.erase(prev(hp.end())); ll nhp = M - atk; if(nhp > 0){ hp.insert(nhp); } } return true; }; ll ok = 250000; ll ng = 0; while(ok - ng > 1){ ll mid = midpoint(ng,ok); if(solve(mid))ok = mid; else ng = mid; } cout << ok << endl; }