結果
| 問題 |
No.3281 Pacific White-sided Dolphin vs Monster
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-07 16:42:30 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 75 ms / 2,000 ms |
| コード長 | 1,010 bytes |
| コンパイル時間 | 834 ms |
| コンパイル使用メモリ | 83,908 KB |
| 実行使用メモリ | 7,724 KB |
| 最終ジャッジ日時 | 2025-11-07 16:42:34 |
| 合計ジャッジ時間 | 4,092 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 51 |
ソースコード
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using LL = long long;
int main() {
int N;
std::cin >> N;
std::vector<LL> H(N);
for (auto& x : H) {
std::cin >> x;
}
std::sort(H.begin(), H.end());
auto check = [&](int x) -> bool {
std::priority_queue<LL> q;
for (int i = 0; i < N - std::max(x - 60, 0); i++) {
q.emplace(H[i]);
}
for (x = std::min(x, 60) - 1; x >= 0; x--) {
if (q.empty()) {
break;
}
auto t = q.top();
q.pop();
t -= (1LL << x);
if (t > 0) {
q.emplace(t);
}
}
return q.empty();
};
int left = N;
int right = N + 60;
while (left < right) {
int mid = (left + right) / 2;
if (check(mid)) {
right = mid;
} else {
left = mid + 1;
}
}
std::cout << left << std::endl;
return 0;
}