結果

問題 No.9 モンスターのレベル上げ
ユーザー kroton
提出日時 2014-11-01 04:58:11
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 525 ms / 5,000 ms
コード長 909 bytes
コンパイル時間 763 ms
コンパイル使用メモリ 70,096 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-23 22:01:45
合計ジャッジ時間 6,013 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
#include <vector>
#include <functional>
using namespace std;

typedef pair<int, int> P;

int N;
int A[1510], B[1510];

int solve(int first){
    priority_queue<P, vector<P>, greater<P>> Q;
    
    for(int i=0;i<N;i++){
        Q.push(make_pair(A[i], 0));
    }
    
    for(int i=0;i<N;i++){
        int k = (first + i) % N;
        
        auto ps = Q.top(); Q.pop();
        Q.push(make_pair(ps.first + B[k] / 2, ps.second + 1));
    }
    
    int res = 0;
    for(int t=0;t<N;t++){
        auto ps = Q.top(); Q.pop();
        res = max(res, ps.second);
    }
    
    return res;
}

int main(){
    cin >> N;
    for(int i=0;i<N;i++)cin >> A[i];
    for(int i=0;i<N;i++)cin >> B[i];
    
    int res = 1 << 30;
    for(int first=0;first<N;first++)res = min(res, solve(first));
    
    cout << res << endl;
    return 0;
}
0