結果

問題 No.9 モンスターのレベル上げ
ユーザー kimiyukikimiyuki
提出日時 2016-12-13 17:25:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 442 ms / 5,000 ms
コード長 1,116 bytes
コンパイル時間 950 ms
コンパイル使用メモリ 80,912 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-06 05:02:14
合計ジャッジ時間 5,521 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 442 ms
4,376 KB
testcase_03 AC 347 ms
4,376 KB
testcase_04 AC 185 ms
4,376 KB
testcase_05 AC 118 ms
4,376 KB
testcase_06 AC 40 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 54 ms
4,380 KB
testcase_09 AC 422 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 362 ms
4,376 KB
testcase_12 AC 291 ms
4,380 KB
testcase_13 AC 187 ms
4,380 KB
testcase_14 AC 422 ms
4,376 KB
testcase_15 AC 384 ms
4,380 KB
testcase_16 AC 7 ms
4,380 KB
testcase_17 AC 244 ms
4,380 KB
testcase_18 AC 205 ms
4,376 KB
testcase_19 AC 5 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
template <class T> void setmax(T & a, T const & b) { if (a < b) a = b; }
template <class T> void setmin(T & a, T const & b) { if (b < a) a = b; }
const int inf = 1e9+7;
int main() {
    int n; cin >> n;
    vector<int> as(n); repeat (i,n) cin >> as[i];
    vector<int> bs(n); repeat (i,n) cin >> bs[i];
    int ans = inf;
    repeat (offset,n) {
        reversed_priority_queue<pair<int, int> > que;
        for (int a : as) que.emplace(a, 0);
        repeat (i,n) {
            int b = bs[(offset + i) % n];
            int lvl, cnt; tie(lvl, cnt) = que.top(); que.pop();
            que.emplace(lvl + b/2, cnt + 1);
        }
        int max_cnt = 0;
        while (not que.empty()) {
            int lvl, cnt; tie(lvl, cnt) = que.top(); que.pop();
            setmax(max_cnt, cnt);
        }
        setmin(ans, max_cnt);
    }
    cout << ans << endl;
    return 0;
}
0