結果

問題 No.9 モンスターのレベル上げ
ユーザー maimai
提出日時 2016-06-14 21:35:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 305 ms / 5,000 ms
コード長 999 bytes
コンパイル時間 1,577 ms
コンパイル使用メモリ 171,048 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-06 04:41:50
合計ジャッジ時間 5,171 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 305 ms
4,376 KB
testcase_03 AC 244 ms
4,376 KB
testcase_04 AC 128 ms
4,376 KB
testcase_05 AC 85 ms
4,380 KB
testcase_06 AC 29 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 38 ms
4,380 KB
testcase_09 AC 299 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 246 ms
4,380 KB
testcase_12 AC 179 ms
4,376 KB
testcase_13 AC 169 ms
4,380 KB
testcase_14 AC 299 ms
4,380 KB
testcase_15 AC 271 ms
4,376 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 175 ms
4,380 KB
testcase_18 AC 148 ms
4,376 KB
testcase_19 AC 4 ms
4,376 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