結果

問題 No.9 モンスターのレベル上げ
ユーザー mamekin
提出日時 2015-01-11 15:00:01
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 751 ms / 5,000 ms
コード長 1,166 bytes
コンパイル時間 960 ms
コンパイル使用メモリ 97,548 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-23 22:12:17
合計ジャッジ時間 7,618 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];
    for(int i=0; i<n; ++i)
        cin >> b[i];

    int ret = INT_MAX;
    for(int i=0; i<n; ++i){
        multiset<pair<int, int> > ms;
        for(int j=0; j<n; ++j)
            ms.insert(make_pair(a[j], 0));

        for(int j=0; j<n; ++j){
            int x = b[(i+j)%n] / 2;
            pair<int, int> p = *ms.begin();
            ms.erase(ms.begin());
            p.first += x;
            ++ p.second;
            ms.insert(p);
        }

        int cnt = 0;
        for(multiset<pair<int, int> >::iterator it=ms.begin(); it!=ms.end(); ++it)
            cnt = max(cnt, it->second);
        ret = min(ret, cnt);
    }
    cout << ret << endl;

    return 0;
}
0