結果

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
int main()
{
    int n;
    while (cin>>n) {
        vector<int> b(n);
        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> a;
        for(int i=0;i<n;++i) {
            int t; cin>>t;
            a.emplace(t, 0);
        }
        for(int& v: b) cin>>v;

        int res=1000000;
        for(int k=0;k<n;++k) {
            auto s=a;
            int cnt=0;
            for(int i=0;i<n;++i) {
                auto x=s.top();
                s.pop();
                x.first+=b[(i+k)%n]/2;
                x.second++;
                cnt=max(cnt, x.second);
                s.push(x);
            }
            res=min(res, cnt);
        }
        cout<<res<<endl;
    }
}
0