結果

問題 No.9 モンスターのレベル上げ
ユーザー fantasiabaeticafantasiabaetica
提出日時 2018-08-02 21:05:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,283 bytes
コンパイル時間 601 ms
コンパイル使用メモリ 65,284 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 21:07:34
合計ジャッジ時間 23,945 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,348 KB
testcase_11 WA -
testcase_12 AC 2,572 ms
4,348 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

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){
            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