結果

問題 No.9 モンスターのレベル上げ
ユーザー xuzijian629xuzijian629
提出日時 2018-11-02 01:08:44
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 455 ms / 5,000 ms
コード長 1,067 bytes
コンパイル時間 2,042 ms
使用メモリ 6,952 KB
最終ジャッジ日時 2022-12-26 05:06:53
合計ジャッジ時間 6,845 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
4,904 KB
testcase_01 AC 2 ms
4,900 KB
testcase_02 AC 455 ms
4,900 KB
testcase_03 AC 361 ms
4,904 KB
testcase_04 AC 189 ms
6,952 KB
testcase_05 AC 122 ms
4,900 KB
testcase_06 AC 42 ms
4,900 KB
testcase_07 AC 2 ms
4,900 KB
testcase_08 AC 57 ms
6,948 KB
testcase_09 AC 441 ms
4,904 KB
testcase_10 AC 0 ms
6,948 KB
testcase_11 AC 375 ms
6,948 KB
testcase_12 AC 271 ms
4,904 KB
testcase_13 AC 195 ms
4,904 KB
testcase_14 AC 442 ms
4,900 KB
testcase_15 AC 403 ms
4,900 KB
testcase_16 AC 7 ms
4,904 KB
testcase_17 AC 256 ms
4,900 KB
testcase_18 AC 216 ms
4,900 KB
testcase_19 AC 5 ms
4,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    // assert(freopen("/Users/xuzijian/yukicoder/input4", "r", stdin));
    int n;
    cin >> n;
    using ii = pair<int, int>;
    priority_queue<ii, vector<ii>, greater<ii>> que;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        que.push(ii(a, 0));
    }

    deque<int> bs;
    for (int i = 0; i < n; i++) {
        int b;
        cin >> b;
        bs.push_back(b);
    }

    int ans = 1e9;
    for (int i = 0; i < n; i++) {
        priority_queue<ii, vector<ii>, greater<ii>> q(que);
        for (int j = 0; j < n; j++) {
            ii m = q.top();
            q.pop();
            m.first += bs[j] / 2;
            m.second++;
            q.push(m);
        }
        int tmp = -1;
        while (q.size()) {
            tmp = max(tmp, q.top().second);
            q.pop();
        }
        ans = min(ans, tmp);
        bs.push_back(bs.front());
        bs.pop_front();
    }   
    cout << ans << endl;
}
0