結果
| 問題 |
No.3281 Pacific White-sided Dolphin vs Monster
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-26 21:37:08 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 132 ms / 2,000 ms |
| コード長 | 1,852 bytes |
| コンパイル時間 | 6,945 ms |
| コンパイル使用メモリ | 356,704 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-10-03 17:35:38 |
| 合計ジャッジ時間 | 10,071 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 51 |
ソースコード
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <stdlib.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
#define rep(i, a, n) for(ll i = a; i < n; i++)
#define rrep(i, a, n) for(ll i = a; i >= n; i--)
#define inr(l, x, r) (l <= x && x < r)
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
//constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;
constexpr int IINF = 1001001001;
constexpr ll INF = 1LL<<60;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
using mint = modint998244353;
ll gcd(ll a, ll b){
if(a%b == 0){
return b;
}else{
return gcd(b, a%b);
}
}
ll lcm(ll a, ll b){
return a*b / gcd(a, b);
}
ll powMod(ll x, ll n, ll mod) {
if (n == 0) return 1 % mod;
ll val = powMod(x, n / 2, mod);
val *= val;
val %= mod;
if (n % 2 == 1) val *= x;
return val % mod;
}
int main() {
ll n; cin >> n;
vector<ll> h(n);
rep(i,0,n) cin >> h[i];
sort(h.begin(), h.end(), greater<ll>());
ll ng = 0, ok = 1e5+30;
vector<ll> pow2(61,1);
rep(i,1,61) pow2[i] = pow2[i-1]*2;
auto f = [&](ll m){
if(m < n) return false;
if(m >= n+60) return true;
priority_queue<ll> pq;
rep(i,0,n) pq.push(h[i]);
rrep(i,m-1,0){
if(pq.empty()) return true;
ll x = pq.top(); pq.pop();
ll at = i >= 60 ? INF : pow2[i];
if(x > at){
pq.push(x - at);
}
}
return pq.empty();
};
while(ok - ng > 1){
ll mid = (ok + ng) / 2;
if(f(mid)) ok = mid;
else ng = mid;
}
cout << ok << endl;
return 0;
}