結果

問題 No.9 モンスターのレベル上げ
ユーザー kyuna
提出日時 2020-04-28 07:32:30
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 265 ms / 5,000 ms
コード長 831 bytes
コンパイル時間 949 ms
コンパイル使用メモリ 83,616 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-23 23:03:54
合計ジャッジ時間 4,138 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
using namespace std;
template<class T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
const int INF = (int)1e9 + 7;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    vector<int> b(n);
    for (auto &bi: b) cin >> bi;
    int mi = INF;
    for (int ofs = 0; ofs < n; ofs++) {
        min_heap<pair<int, int>> pq;
        for (auto &ai: a) pq.emplace(ai, 0);
        int ma = 0;
        for (int i = 0; i < n; i++) {
            int cur = b[(i + ofs) % n];
            int lvl, cnt; tie(lvl, cnt) = pq.top(); pq.pop();
            pq.emplace(lvl + cur / 2, cnt + 1);
            ma = max(ma, cnt + 1);
        }
        mi = min(mi, ma);
    }
    cout << mi << endl;
    return 0;
}
0