結果

問題 No.9 モンスターのレベル上げ
ユーザー kyunakyuna
提出日時 2020-04-28 07:30:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 438 ms / 5,000 ms
コード長 865 bytes
コンパイル時間 1,005 ms
コンパイル使用メモリ 83,964 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-15 15:18:19
合計ジャッジ時間 5,708 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 438 ms
4,380 KB
testcase_03 AC 350 ms
4,380 KB
testcase_04 AC 183 ms
4,380 KB
testcase_05 AC 119 ms
4,380 KB
testcase_06 AC 41 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 54 ms
4,380 KB
testcase_09 AC 424 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 372 ms
4,380 KB
testcase_12 AC 295 ms
4,384 KB
testcase_13 AC 199 ms
4,384 KB
testcase_14 AC 426 ms
4,380 KB
testcase_15 AC 389 ms
4,380 KB
testcase_16 AC 7 ms
4,380 KB
testcase_17 AC 249 ms
4,384 KB
testcase_18 AC 209 ms
4,384 KB
testcase_19 AC 5 ms
4,380 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