結果
| 問題 |
No.3281 Pacific White-sided Dolphin vs Monster
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-26 22:54:45 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,106 bytes |
| コンパイル時間 | 1,950 ms |
| コンパイル使用メモリ | 204,340 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-09-26 22:54:55 |
| 合計ジャッジ時間 | 4,322 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 46 WA * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N; cin >> N;
vector<long long> H(N);
for(auto &h : H) cin >> h;
sort(H.rbegin(),H.rend());
auto memo = H;
long long answer = 0,pos = 0,p = 1,inf = 2e18;
while(pos < N){
if(H.at(pos) <= 0) break;
answer++;
if(H.at(pos) > p) H.back() -= p;
else pos++;
p = min(p*2,inf);
}
H = memo;
p = 1;
long long answer2 = 0;
for(auto h : H){
while(h > 0) h -= p,p = min(p*2,inf),answer2++;
}
answer = min(answer,answer2);
answer2 = 0;
for(int i=0; i<60; i++){
long long i2 = 1LL<<i;
for(auto &h : H) if(h > 0 && h <= i2){answer2++,h = 0; break;}
if(answer2 == i+1) continue;
for(auto &h : H) if((h&i2) && (h%(i2) == 0)){answer2++,h -= i2; break;}
if(answer2 == i+1) continue;
for(auto &h : H) if(h > 0){h -= i2,answer2++; break;}
}
for(auto h : H) answer2 += h>0;
answer = min(answer,answer2);
cout << answer << endl;
}