結果

問題 No.9 モンスターのレベル上げ
ユーザー finefine
提出日時 2016-03-31 20:41:57
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 403 ms / 5,000 ms
コード長 857 bytes
コンパイル時間 1,093 ms
使用メモリ 6,952 KB
最終ジャッジ日時 2023-01-21 15:31:50
合計ジャッジ時間 5,669 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
6,952 KB
testcase_01 AC 1 ms
6,952 KB
testcase_02 AC 403 ms
4,904 KB
testcase_03 AC 321 ms
4,900 KB
testcase_04 AC 168 ms
4,904 KB
testcase_05 AC 110 ms
4,900 KB
testcase_06 AC 38 ms
4,900 KB
testcase_07 AC 2 ms
4,904 KB
testcase_08 AC 50 ms
4,900 KB
testcase_09 AC 390 ms
4,904 KB
testcase_10 AC 1 ms
4,904 KB
testcase_11 AC 324 ms
6,948 KB
testcase_12 AC 243 ms
4,900 KB
testcase_13 AC 181 ms
4,904 KB
testcase_14 AC 391 ms
4,900 KB
testcase_15 AC 356 ms
4,904 KB
testcase_16 AC 7 ms
4,900 KB
testcase_17 AC 227 ms
4,900 KB
testcase_18 AC 190 ms
6,952 KB
testcase_19 AC 4 ms
6,948 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