結果

問題 No.9 モンスターのレベル上げ
ユーザー TomorrowNextTomorrowNext
提出日時 2021-04-09 01:25:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 483 ms / 5,000 ms
コード長 1,077 bytes
コンパイル時間 1,636 ms
コンパイル使用メモリ 173,380 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-06 09:48:26
合計ジャッジ時間 7,133 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 483 ms
4,376 KB
testcase_03 AC 388 ms
4,376 KB
testcase_04 AC 203 ms
4,380 KB
testcase_05 AC 130 ms
4,380 KB
testcase_06 AC 45 ms
4,376 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 59 ms
4,376 KB
testcase_09 AC 458 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 415 ms
4,380 KB
testcase_12 AC 326 ms
4,376 KB
testcase_13 AC 397 ms
4,380 KB
testcase_14 AC 477 ms
4,376 KB
testcase_15 AC 435 ms
4,376 KB
testcase_16 AC 8 ms
4,376 KB
testcase_17 AC 275 ms
4,376 KB
testcase_18 AC 220 ms
4,376 KB
testcase_19 AC 5 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

using namespace std;
using ll = long long;

void Main() {
    int N;
    cin >> N;
    vector<int> A(N, 0), B(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < N; ++i) {
        cin >> B[i];
    }

    typedef pair<pair<int, int>, int> level_nb_id;
    int ans = N;
    for (int i = 0; i < N; ++i) {
        priority_queue<level_nb_id, vector<level_nb_id>, greater<level_nb_id>> q;
        for (int j = 0; j < N; ++j) {
            q.push(make_pair(make_pair(A[j], 0), j));
        }
        for (int j = 0; j < N; ++j) {
            level_nb_id curr = q.top();
            q.pop();
            curr.first.first += B[(i + j) % N] / 2;
            curr.first.second += 1;
            q.push(curr);
        }
        int temp = 0;
        for (int j = 0; j < N; ++j) {
            temp = max(temp, q.top().first.second);
            q.pop();
        }
        ans = min(ans, temp);
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}
0