結果

問題 No.9 モンスターのレベル上げ
ユーザー commycommy
提出日時 2018-08-10 22:31:31
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 425 ms / 5,000 ms
コード長 1,292 bytes
コンパイル時間 607 ms
使用メモリ 3,576 KB
最終ジャッジ日時 2022-11-22 22:17:17
合計ジャッジ時間 5,651 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
3,412 KB
testcase_01 AC 1 ms
3,536 KB
testcase_02 AC 425 ms
3,540 KB
testcase_03 AC 339 ms
3,484 KB
testcase_04 AC 177 ms
3,464 KB
testcase_05 AC 116 ms
3,380 KB
testcase_06 AC 38 ms
3,424 KB
testcase_07 AC 2 ms
3,420 KB
testcase_08 AC 51 ms
3,556 KB
testcase_09 AC 399 ms
3,484 KB
testcase_10 AC 1 ms
3,448 KB
testcase_11 AC 338 ms
3,400 KB
testcase_12 AC 238 ms
3,456 KB
testcase_13 AC 177 ms
3,528 KB
testcase_14 AC 397 ms
3,484 KB
testcase_15 AC 365 ms
3,480 KB
testcase_16 AC 7 ms
3,480 KB
testcase_17 AC 233 ms
3,576 KB
testcase_18 AC 195 ms
3,392 KB
testcase_19 AC 4 ms
3,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <utility>
#include <functional>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    int N;
    cin >> N;
    priority_queue<pii, vector<pii>, greater<pii>> pq;
    REP(i, 0, N) {
        int a;
        cin >> a;
        pq.emplace(a, 0);
    }
    vector<int> B(N);
    REP(i, 0, N) {
        cin >> B[i];
    }
    int ans = N;
    REP(i, 0, N) {
        auto pqt = pq;
        REP(j, 0, N) {
            int idx = (i + j) % N;
            auto elem = pqt.top();
            pqt.pop();
            elem.first += (B[idx] / 2);
            elem.second++;
            pqt.push(elem);
        }
        int tmp = 0;
        while (pqt.size()) {
            tmp = max(tmp, pqt.top().second);
            pqt.pop();
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}
0