結果

問題 No.9 モンスターのレベル上げ
ユーザー finefine
提出日時 2016-03-31 20:41:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 410 ms / 5,000 ms
コード長 857 bytes
コンパイル時間 1,308 ms
コンパイル使用メモリ 150,688 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 04:32:12
合計ジャッジ時間 5,742 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 410 ms
4,376 KB
testcase_03 AC 322 ms
4,376 KB
testcase_04 AC 168 ms
4,380 KB
testcase_05 AC 111 ms
4,376 KB
testcase_06 AC 39 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 50 ms
4,380 KB
testcase_09 AC 392 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 324 ms
4,380 KB
testcase_12 AC 244 ms
4,380 KB
testcase_13 AC 183 ms
4,376 KB
testcase_14 AC 388 ms
4,380 KB
testcase_15 AC 357 ms
4,376 KB
testcase_16 AC 7 ms
4,384 KB
testcase_17 AC 231 ms
4,380 KB
testcase_18 AC 193 ms
4,380 KB
testcase_19 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> M;
typedef priority_queue<M, vector<M>, greater<M> > P;

int sol(P pq, int s, int n, const int* b) {
    int ans = 0, idx;
    for (int i = 0; i < n; i++) {
        idx = (i + s) % n;
        M x = pq.top();
        pq.pop();
        x.first += b[idx] / 2;
        x.second++;
        pq.push(x);
    }
    while (!pq.empty()) {
        M x = pq.top();
        pq.pop();
        ans = max(ans, x.second);
    }
    return ans;
}

int main(){
    int n, tmp, b[1500], ans;
    cin >> n;
    P pq;
    for(int i = 0; i < n; i++) {
        cin >> tmp;
        pq.push(make_pair(tmp, 0));
    }
    for(int i = 0; i < n; i++) {
        cin >> b[i];
    }
    ans = n;
    for(int i = 0; i < n; i++) {
        ans = min(ans, sol(pq, i, n, b));
    }
    cout << ans << "\n"; 
    return 0;
}
0