結果

問題 No.9 モンスターのレベル上げ
ユーザー kimiyuki
提出日時 2016-12-13 17:23:00
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,078 bytes
コンパイル時間 1,017 ms
コンパイル使用メモリ 81,584 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-30 01:07:44
合計ジャッジ時間 5,641 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 8 WA * 12
権限があれば一括ダウンロードができます

ソースコード

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);
        for (int b : bs) {
            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