結果

問題 No.9 モンスターのレベル上げ
ユーザー ふーらくたるふーらくたる
提出日時 2016-06-24 11:31:12
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 271 ms / 5,000 ms
コード長 1,052 bytes
コンパイル時間 572 ms
コンパイル使用メモリ 67,472 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 04:42:54
合計ジャッジ時間 3,853 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 271 ms
4,380 KB
testcase_03 AC 216 ms
4,376 KB
testcase_04 AC 114 ms
4,380 KB
testcase_05 AC 75 ms
4,380 KB
testcase_06 AC 26 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 34 ms
4,380 KB
testcase_09 AC 265 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 205 ms
4,376 KB
testcase_12 AC 167 ms
4,380 KB
testcase_13 AC 151 ms
4,376 KB
testcase_14 AC 267 ms
4,376 KB
testcase_15 AC 240 ms
4,376 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 154 ms
4,376 KB
testcase_18 AC 130 ms
4,376 KB
testcase_19 AC 3 ms
4,384 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