結果

問題 No.9 モンスターのレベル上げ
ユーザー H3PO4H3PO4
提出日時 2023-02-19 16:07:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 395 ms / 5,000 ms
コード長 1,016 bytes
コンパイル時間 1,945 ms
コンパイル使用メモリ 81,096 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-27 21:36:15
合計ジャッジ時間 6,124 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 391 ms
4,376 KB
testcase_03 AC 315 ms
4,376 KB
testcase_04 AC 165 ms
4,376 KB
testcase_05 AC 111 ms
4,380 KB
testcase_06 AC 38 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 49 ms
4,376 KB
testcase_09 AC 387 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 327 ms
4,380 KB
testcase_12 AC 275 ms
4,376 KB
testcase_13 AC 183 ms
4,376 KB
testcase_14 AC 395 ms
4,380 KB
testcase_15 AC 354 ms
4,376 KB
testcase_16 AC 6 ms
4,380 KB
testcase_17 AC 231 ms
4,376 KB
testcase_18 AC 193 ms
4,376 KB
testcase_19 AC 5 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <queue>

int main() {
    int N;
    std::cin >> N;
    std::vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) { std::cin >> A.at(i); }
    for (int i = 0; i < N; i++) { std::cin >> B.at(i); }

    int ans = N;
    for (int i = 0; i < N; i++) {
        std::priority_queue<
                std::pair<int, int>,
                std::vector<std::pair<int, int>>,
                std::greater<std::pair<int, int>>> q;
        for (int j = 0; j < N; j++) { q.emplace(A.at(j), 0); }
        for (int j = 0; j < N; j++) {
            auto x = q.top();
            q.pop();
            int k = i + j;
            if (k >= N) { k -= N; }
            x.first += B.at(k) / 2;
            x.second += 1;
            q.emplace(x);
        }
        int tmp = 0;
        for (int j = 0; j < N; j++) {
            if (tmp < q.top().second) { tmp = q.top().second; }
            q.pop();
        }
        if (ans > tmp) { ans = tmp; }
    }
    std::cout << ans << std::endl;
}
0