結果

問題 No.9 モンスターのレベル上げ
ユーザー face4face4
提出日時 2018-09-06 16:40:36
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 511 ms / 5,000 ms
コード長 847 bytes
コンパイル時間 576 ms
使用メモリ 3,600 KB
最終ジャッジ日時 2022-12-27 21:09:42
合計ジャッジ時間 6,277 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
3,520 KB
testcase_01 AC 2 ms
3,520 KB
testcase_02 AC 511 ms
3,548 KB
testcase_03 AC 407 ms
3,504 KB
testcase_04 AC 214 ms
3,480 KB
testcase_05 AC 138 ms
3,356 KB
testcase_06 AC 47 ms
3,464 KB
testcase_07 AC 2 ms
3,476 KB
testcase_08 AC 63 ms
3,412 KB
testcase_09 AC 496 ms
3,560 KB
testcase_10 AC 1 ms
3,340 KB
testcase_11 AC 430 ms
3,388 KB
testcase_12 AC 318 ms
3,388 KB
testcase_13 AC 226 ms
3,432 KB
testcase_14 AC 497 ms
3,540 KB
testcase_15 AC 451 ms
3,600 KB
testcase_16 AC 8 ms
3,428 KB
testcase_17 AC 290 ms
3,504 KB
testcase_18 AC 241 ms
3,496 KB
testcase_19 AC 5 ms
3,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    int n;
    cin >> n;

    int a[n], b[n];
    for(int i = 0; i < n; i++)  cin >> a[i];
    for(int i = 0; i < n; i++)  cin >> b[i];

    int ans = 10001;

    for(int i = 0; i < n; i++){
        priority_queue<pair<int,int>> pq;
        for(int j = 0; j < n; j++)  pq.push(make_pair(-a[j], 0));

        for(int j = 0; j < n; j++){
            int encount = b[(i+j)%n];
            pair<int,int> monster = pq.top(); pq.pop();
            monster.first -= encount/2;
            monster.second--;
            pq.push(monster);
        }

        int tmpmax = 0;
        while(!pq.empty()){
            pair<int,int> p = pq.top(); pq.pop();
            tmpmax = max(tmpmax, -p.second);
        }
        ans = min(ans, tmpmax);
    }

    cout << ans << endl;

    return 0;
}
0