結果

問題 No.9 モンスターのレベル上げ
コンテスト
ユーザー KKT89
提出日時 2026-07-12 01:24:53
言語 C++23
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 156 ms / 5,000 ms
+ 832µs
コード長 1,049 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,121 ms
コンパイル使用メモリ 342,212 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-12 01:25:03
合計ジャッジ時間 5,283 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    vector<int> a(n), b(n);
    for (int& x : a) cin >> x;
    for (int& x : b) cin >> x;

    int ans = n;

    for (int start = 0; start < n; ++start) {
        // (現在レベル, 戦闘回数, モンスター番号)
        priority_queue<
            tuple<int, int, int>,
            vector<tuple<int, int, int>>,
            greater<tuple<int, int, int>>
        > pq;

        for (int i = 0; i < n; ++i) {
            pq.emplace(a[i], 0, i);
        }

        int mx = 0;

        for (int k = 0; k < n; ++k) {
            auto [level, cnt, id] = pq.top();
            pq.pop();

            level += b[(start + k) % n] / 2;
            cnt++;

            mx = max(mx, cnt);
            pq.emplace(level, cnt, id);

            // これ以降、最大戦闘回数が減ることはない
            if (mx >= ans) break;
        }

        ans = min(ans, mx);
    }

    cout << ans << '\n';
}
0