結果

問題 No.9 モンスターのレベル上げ
ユーザー fantasiabaeticafantasiabaetica
提出日時 2018-08-02 21:11:01
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2,685 ms / 5,000 ms
コード長 1,308 bytes
コンパイル時間 644 ms
コンパイル使用メモリ 65,108 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 21:09:26
合計ジャッジ時間 25,033 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2,685 ms
4,348 KB
testcase_03 AC 1,853 ms
4,348 KB
testcase_04 AC 757 ms
4,348 KB
testcase_05 AC 421 ms
4,348 KB
testcase_06 AC 95 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 144 ms
4,348 KB
testcase_09 AC 2,537 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2,661 ms
4,348 KB
testcase_12 AC 2,675 ms
4,348 KB
testcase_13 AC 2,663 ms
4,348 KB
testcase_14 AC 2,535 ms
4,348 KB
testcase_15 AC 2,241 ms
4,348 KB
testcase_16 AC 9 ms
4,348 KB
testcase_17 AC 1,188 ms
4,348 KB
testcase_18 AC 925 ms
4,348 KB
testcase_19 AC 5 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define max_int 2147483647;
using namespace std;

int N;
// a[i]は自分のレベル*2000+戦闘回数 b[i]は相手のレベル
// t[i]はループのたびa[i]をコピー
int a[1500], b[1500], t[1500];

// 次に先頭に出すモンスターを選ぶ
int which_next_battle(){
    int min = max_int;
    int next_battle = 0;
    FOR(i, 0, N){
        if (t[i] < min){
            min = t[i];
            next_battle = i;
        }
    }
    return next_battle;
}


int max_battle_from_i(int i){
    int max_battle_count = 0;
    FOR(j, 0, N){
        int next_battle = which_next_battle();
        int enemy = b[(j + i) % N];
        t[next_battle] += (enemy / 2) * 2000 + 1;
        max_battle_count = max(max_battle_count, t[next_battle] % 2000);
    }
    return max_battle_count;
}

int main() {
    cin >> N;
    FOR(i, 0, N){
        int tmp;
        cin >> tmp;
        a[i] = tmp * 2000;
    }
    FOR(i, 0, N){
        cin >> b[i];
    }

    int min_max_battle = max_int;
    // i番目から戦闘開始
    FOR(i, 0, N){
        FOR(i, 0, N){
            t[i] = a[i];
        }
        int max_battle = max_battle_from_i(i);
        min_max_battle = min(min_max_battle, max_battle);
    }
    cout << min_max_battle << endl;
}
0