結果

問題 No.9 モンスターのレベル上げ
ユーザー 👑 maimai
提出日時 2016-06-14 21:35:45
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 307 ms / 5,000 ms
コード長 999 bytes
コンパイル時間 1,417 ms
使用メモリ 6,952 KB
最終ジャッジ日時 2023-01-21 15:44:38
合計ジャッジ時間 5,229 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
6,952 KB
testcase_01 AC 1 ms
4,900 KB
testcase_02 AC 307 ms
4,904 KB
testcase_03 AC 243 ms
4,900 KB
testcase_04 AC 128 ms
6,948 KB
testcase_05 AC 84 ms
4,900 KB
testcase_06 AC 29 ms
6,948 KB
testcase_07 AC 2 ms
6,952 KB
testcase_08 AC 38 ms
6,948 KB
testcase_09 AC 298 ms
6,948 KB
testcase_10 AC 1 ms
4,904 KB
testcase_11 AC 239 ms
4,900 KB
testcase_12 AC 177 ms
4,904 KB
testcase_13 AC 171 ms
4,904 KB
testcase_14 AC 299 ms
6,952 KB
testcase_15 AC 273 ms
4,904 KB
testcase_16 AC 5 ms
4,900 KB
testcase_17 AC 175 ms
4,904 KB
testcase_18 AC 147 ms
4,904 KB
testcase_19 AC 4 ms
4,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;
typedef long long int ll;

int calc(vector<int> &ev,vector<int> &mv,int offset){
    priority_queue<pair<int,int>> pq;
    for (int e:mv)
        pq.push(make_pair(-e,0));
    
    int i,j,max=0;
    for (j=0;j<ev.size();j++){
        i=(j+offset)%ev.size();
        int p=-pq.top().first;
        int q=-pq.top().second;pq.pop();
        p+=ev[i]/2;
        if (max<++q) max=q;
        pq.push(make_pair(-p,-q));
    }
    return max;
}

int main(){
    int i,j,k,l;
    int x,y,d;
    int n,m;
    
    cin >> n;
    vector<int> mee(n);
    vector<int> ene(n);
    
    for (i=0;i<n;i++){
        scanf("%d",&j);
        mee[i]=j;
    }
    for (i=0;i<n;i++){
        scanf("%d",&j);
        ene[i]=j;
    }
    
    int min=0xFFFF;
    for (i=0;i<n;i++){
        int u=calc(ene,mee,i);
        if (min>u) min=u;
    }
    cout<<min<<endl;
    
    
    return 0;
    
}
0