結果
問題 |
No.3281 Pacific White-sided Dolphin vs Monster
|
ユーザー |
|
提出日時 | 2025-09-27 02:20:22 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 110 ms / 2,000 ms |
コード長 | 662 bytes |
コンパイル時間 | 1,155 ms |
コンパイル使用メモリ | 106,036 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-27 02:20:27 |
合計ジャッジ時間 | 5,078 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 50 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; using ll = long long; int main() { int N;cin >> N; vector<ll> H(N); for (int i = 0;i < N;i++) cin >> H[i]; ll ng = -1; ll ok = 1e7; sort(H.begin(),H.end()); while (ok-ng > 1) { ll mid = (ok + ng) / 2; vector<ll> now = H; ll K = mid; while (K >= 0 and !now.empty()) { if (K >= 60) { now.pop_back(); } else { sort(now.begin(),now.end()); if (now.back() <= (1LL << K)) { now.pop_back(); } else { now.back() -= (1LL << K); } } K--; } if (now.empty()) { ok = mid; } else { ng = mid; } } cout << ok + 1 << endl; }