結果

問題 No.9 モンスターのレベル上げ
ユーザー kyunakyuna
提出日時 2020-04-28 07:30:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 427 ms / 5,000 ms
コード長 865 bytes
コンパイル時間 1,036 ms
コンパイル使用メモリ 83,844 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-03 02:37:09
合計ジャッジ時間 5,572 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 427 ms
5,248 KB
testcase_03 AC 343 ms
5,376 KB
testcase_04 AC 178 ms
5,376 KB
testcase_05 AC 115 ms
5,376 KB
testcase_06 AC 40 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 54 ms
5,376 KB
testcase_09 AC 417 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 354 ms
5,376 KB
testcase_12 AC 305 ms
5,376 KB
testcase_13 AC 194 ms
5,376 KB
testcase_14 AC 422 ms
5,376 KB
testcase_15 AC 380 ms
5,376 KB
testcase_16 AC 8 ms
5,376 KB
testcase_17 AC 244 ms
5,376 KB
testcase_18 AC 201 ms
5,376 KB
testcase_19 AC 5 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
using namespace std;
template<class T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
const int INF = (int)1e9 + 7;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    vector<int> b(n);
    for (auto &bi: b) cin >> bi;
    int mi = INF;
    for (int ofs = 0; ofs < n; ofs++) {
        min_heap<pair<int, int>> pq;
        for (auto &ai: a) pq.emplace(ai, 0);
        for (int i = 0; i < n; i++) {
            int cur = b[(i + ofs) % n];
            int lvl, cnt; tie(lvl, cnt) = pq.top(); pq.pop();
            pq.emplace(lvl + cur / 2, cnt + 1);
        }
        int ma = 0;
        while (!pq.empty()) ma = max(ma, pq.top().second), pq.pop();
        mi = min(mi, ma);
    }
    cout << mi << endl;
    return 0;
}
0