結果

問題 No.9 モンスターのレベル上げ
ユーザー ふーらくたるふーらくたる
提出日時 2016-06-24 11:31:12
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 271 ms / 5,000 ms
コード長 1,052 bytes
コンパイル時間 766 ms
使用メモリ 3,592 KB
最終ジャッジ日時 2023-01-21 15:46:05
合計ジャッジ時間 3,921 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
3,544 KB
testcase_01 AC 2 ms
3,464 KB
testcase_02 AC 271 ms
3,560 KB
testcase_03 AC 216 ms
3,492 KB
testcase_04 AC 113 ms
3,424 KB
testcase_05 AC 74 ms
3,428 KB
testcase_06 AC 25 ms
3,544 KB
testcase_07 AC 2 ms
3,568 KB
testcase_08 AC 34 ms
3,424 KB
testcase_09 AC 264 ms
3,440 KB
testcase_10 AC 1 ms
3,400 KB
testcase_11 AC 207 ms
3,592 KB
testcase_12 AC 167 ms
3,504 KB
testcase_13 AC 151 ms
3,552 KB
testcase_14 AC 265 ms
3,580 KB
testcase_15 AC 241 ms
3,508 KB
testcase_16 AC 6 ms
3,416 KB
testcase_17 AC 155 ms
3,544 KB
testcase_18 AC 130 ms
3,544 KB
testcase_19 AC 3 ms
3,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <utility>
#include <queue>
using namespace std;

typedef pair<int, int> P;

const int kINF = 1 << 28;
const int kMAX_N = 1510;

int N;
int A[kMAX_N], B[kMAX_N];

void Solve() {
    int answer = kINF;
    for (int i = 0; i < N; i++) {
        priority_queue<P, vector<P>, greater<P> > que;
        for (int m = 0; m < N; m++) {
            que.push(P(A[m], 0));
        }
        int max_fight = 0;
        for (int j = 0; j < N; j++) {
            int enemy = (i + j) % N;
            P monster = que.top(); que.pop();
            monster.first += B[enemy] / 2;
            monster.second += 1;

            que.push(monster);

            max_fight = max(max_fight, monster.second);
        }

        answer = min(answer, max_fight);
    }
    cout << answer << endl;
}

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

    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }

    Solve();

    return 0;
}
0