結果

問題 No.9 モンスターのレベル上げ
ユーザー kimiyukikimiyuki
提出日時 2016-12-13 17:23:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,078 bytes
コンパイル時間 2,053 ms
コンパイル使用メモリ 81,136 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-20 01:57:31
合計ジャッジ時間 5,678 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 344 ms
4,380 KB
testcase_12 AC 267 ms
4,376 KB
testcase_13 AC 175 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 224 ms
4,380 KB
testcase_18 AC 191 ms
4,380 KB
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

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