結果

問題 No.3281 Pacific White-sided Dolphin vs Monster
ユーザー Carpenters-Cat
提出日時 2025-09-26 21:47:56
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 279 ms / 2,000 ms
コード長 653 bytes
コンパイル時間 1,956 ms
コンパイル使用メモリ 203,440 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-26 21:48:04
合計ジャッジ時間 7,145 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
bool OK(const vector<ll>& A, int n, int d) {
	priority_queue<ll> pque;
	for (int i = 0; i < n; i ++) pque.push(A[i]);
	for (int i = d-1; i >= 0; i --) {
		if (pque.empty()) break;
		ll a = pque.top();
		pque.pop();
		a -= (1ll << i);
		if (a > 0) {
			pque.push(a);
		}
	}
	return pque.empty();
}
int main () {
	int N;
	cin >> N;
	std::vector<ll> A(N);
	for (auto& a : A) cin >> a;
	sort(A.begin(), A.end());
	for (int i = 1; i <= 60; i ++) {
		if (OK(A, N, i)) {
			cout << i << endl;
			return 0;
		}
	}
	int n = 1;
	while (OK(A, n, 60)) n ++;
	n --;
	cout << 60 + (N - n) << endl;
}
0