結果

問題 No.9 モンスターのレベル上げ
ユーザー fantasiabaeticafantasiabaetica
提出日時 2018-08-02 20:58:59
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,560 bytes
コンパイル時間 1,108 ms
コンパイル使用メモリ 56,472 KB
実行使用メモリ 8,696 KB
最終ジャッジ日時 2023-10-19 21:06:52
合計ジャッジ時間 7,907 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define INT_MAX 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 level = INT_MAX;
    int battle_count = INT_MAX;
    int next_battle = 0;
    FOR(i, 0, N){
        if (t[i] / 2000 < level){
            level = t[i] / 2000;
            battle_count = t[i] % 2000;
            next_battle = i;
        } else if (t[i] / 2000 == level){
            if(t[i] % 2000 < battle_count){
                level = t[i] / 2000;
                battle_count = t[i] % 2000;
                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 = INT_MAX;
    // 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