結果
問題 |
No.9 モンスターのレベル上げ
|
ユーザー |
|
提出日時 | 2016-03-31 20:41:57 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 383 ms / 5,000 ms |
コード長 | 857 bytes |
コンパイル時間 | 1,395 ms |
コンパイル使用メモリ | 164,636 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-23 23:21:26 |
合計ジャッジ時間 | 5,454 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> M; typedef priority_queue<M, vector<M>, greater<M> > P; int sol(P pq, int s, int n, const int* b) { int ans = 0, idx; for (int i = 0; i < n; i++) { idx = (i + s) % n; M x = pq.top(); pq.pop(); x.first += b[idx] / 2; x.second++; pq.push(x); } while (!pq.empty()) { M x = pq.top(); pq.pop(); ans = max(ans, x.second); } return ans; } int main(){ int n, tmp, b[1500], ans; cin >> n; P pq; for(int i = 0; i < n; i++) { cin >> tmp; pq.push(make_pair(tmp, 0)); } for(int i = 0; i < n; i++) { cin >> b[i]; } ans = n; for(int i = 0; i < n; i++) { ans = min(ans, sol(pq, i, n, b)); } cout << ans << "\n"; return 0; }