結果

問題 No.9 モンスターのレベル上げ
ユーザー Mi_SawaMi_Sawa
提出日時 2015-04-05 00:13:53
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 251 ms / 5,000 ms
コード長 1,634 bytes
コンパイル時間 1,180 ms
使用メモリ 6,952 KB
最終ジャッジ日時 2023-01-21 14:24:58
合計ジャッジ時間 4,678 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
4,904 KB
testcase_01 AC 2 ms
4,904 KB
testcase_02 AC 251 ms
4,900 KB
testcase_03 AC 201 ms
4,900 KB
testcase_04 AC 104 ms
6,952 KB
testcase_05 AC 68 ms
4,904 KB
testcase_06 AC 23 ms
4,900 KB
testcase_07 AC 2 ms
4,900 KB
testcase_08 AC 31 ms
4,904 KB
testcase_09 AC 246 ms
6,952 KB
testcase_10 AC 1 ms
4,904 KB
testcase_11 AC 190 ms
4,904 KB
testcase_12 AC 172 ms
6,948 KB
testcase_13 AC 150 ms
4,900 KB
testcase_14 AC 248 ms
4,904 KB
testcase_15 AC 224 ms
6,948 KB
testcase_16 AC 5 ms
4,900 KB
testcase_17 AC 142 ms
4,904 KB
testcase_18 AC 118 ms
4,904 KB
testcase_19 AC 3 ms
4,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define all(x) begin(x),end(x)
#define rall(x) (x).rbegin(),(x).rend()
#define REP(i,b,n) for(int i=(int)(b);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define repsz(i,v) rep(i,(v).size())
#define aur auto&
#define bit(n) (1LL<<(n))
#define eb emplace_back
#define mt make_tuple
#define fst first
#define snd second
using namespace std;
typedef long long ll;
//#define int long long
template<class C>int size(const C &c){ return c.size(); }
template<class T>bool chmin(T&a,const T&b){if(a<=b)return false;a=b;return true;}
template<class T>bool chmax(T&a,const T&b){if(a>=b)return false;a=b;return true;}

template<typename T> std::vector<T> get_vec(size_t n){//{{{
    std::vector<T> res; res.reserve(n);
    for(size_t i = 0; i < n; ++i){ T x; std::cin >> x; res.emplace_back(x); }
    return res;
}//}}}

bool solve(){
    int n; cin >> n;
    auto a = get_vec<int>(n), b = get_vec<int>(n);
    b.insert(end(b), all(b));
    int res = numeric_limits<int>::max();
    rep(p, n){
        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
        for(aur x : a) pq.emplace(x, 0);
        int top = 0;
        rep(i, n){
            int level, battle;
            tie(level, battle) = pq.top(); pq.pop();
            pq.emplace(level + b[p+i]/2, ++battle);
            chmax(top, battle);
        }
        chmin(res, top);
    }
    cout << res << endl;
    return true;
}
signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}
// vim:set foldmethod=marker commentstring=//%s:
0