結果
問題 |
No.3281 Pacific White-sided Dolphin vs Monster
|
ユーザー |
|
提出日時 | 2025-09-26 22:06:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,148 bytes |
コンパイル時間 | 1,978 ms |
コンパイル使用メモリ | 201,108 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-09-26 22:06:19 |
合計ジャッジ時間 | 4,619 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 44 WA * 6 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<ll> a(n); for(auto &&v : a) cin >> v; sort(a.begin(), a.end()); ll p = 1; int ans = 0, cnt = 0; constexpr ll th = 1'000'000'000'000'000'000ll; while(p < th && cnt < n){ bool flg = false; for(int i = 0; i < n; i++){ if(a[i] == 0) continue; if(a[i] <= p){ p = min(2 * p, th); ans++; cnt++; a[i] = 0; flg = true; break; } } if(flg) continue; int pos = 0, mn = -61; for(int i = 0; i < n; i++){ if(a[i] == 0) continue; int bcnt = __builtin_popcountll(a[i]) - __builtin_popcountll(a[i] - p); if(bcnt > mn){ mn = bcnt; pos = i; } } a[pos] -= p; ans++; p = min(2 * p, th); } for(int i = 0; i < n; i++){ if(a[i] >= 1) ans++; } cout << ans << '\n'; }