結果

問題 No.9 モンスターのレベル上げ
ユーザー commycommy
提出日時 2018-08-10 22:31:31
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 385 ms / 5,000 ms
コード長 1,292 bytes
コンパイル時間 1,024 ms
コンパイル使用メモリ 83,984 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 13:36:37
合計ジャッジ時間 4,753 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 385 ms
4,348 KB
testcase_03 AC 310 ms
4,348 KB
testcase_04 AC 162 ms
4,348 KB
testcase_05 AC 106 ms
4,348 KB
testcase_06 AC 37 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 48 ms
4,348 KB
testcase_09 AC 377 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 308 ms
4,348 KB
testcase_12 AC 233 ms
4,348 KB
testcase_13 AC 172 ms
4,348 KB
testcase_14 AC 377 ms
4,348 KB
testcase_15 AC 344 ms
4,348 KB
testcase_16 AC 7 ms
4,348 KB
testcase_17 AC 218 ms
4,348 KB
testcase_18 AC 183 ms
4,348 KB
testcase_19 AC 5 ms
4,348 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