結果

問題 No.9 モンスターのレベル上げ
ユーザー nanophoto12nanophoto12
提出日時 2016-02-17 01:09:20
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 199 ms / 5,000 ms
コード長 1,957 bytes
コンパイル時間 723 ms
コンパイル使用メモリ 93,416 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-06 04:28:59
合計ジャッジ時間 3,582 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 199 ms
4,376 KB
testcase_03 AC 160 ms
4,376 KB
testcase_04 AC 80 ms
4,376 KB
testcase_05 AC 56 ms
4,376 KB
testcase_06 AC 20 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 25 ms
4,376 KB
testcase_09 AC 193 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 144 ms
4,376 KB
testcase_12 AC 173 ms
4,380 KB
testcase_13 AC 143 ms
4,376 KB
testcase_14 AC 196 ms
4,376 KB
testcase_15 AC 177 ms
4,380 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 112 ms
4,376 KB
testcase_18 AC 91 ms
4,380 KB
testcase_19 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
#include <sstream>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <functional>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

class CompareDist
{
public:
    bool operator()(pair<int,int> n1,pair<int,int> n2) {
        if(n1.first == n2.first)
        {
            return n1.second > n2.second;
        }
        return n1.first>n2.first;
    }
};
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    FOR(x, n)
    {
        cin >> a[x];
    }
    vector<int> b(n);
    FOR(x, n)
    {
        cin >> b[x];
    }
    priority_queue<pair<int,int>, vector<pair<int,int>>,CompareDist> source;
    FOR(y, n)
    {
        source.push(make_pair(a[y], 0));
    }
    int minValue = 1000000000;
    FOR(s, n)
    {
        int maxValue = 0;
        priority_queue<pair<int,int>, vector<pair<int,int>>,CompareDist> copy = source;
        FOR(x, n)
        {
            int index = (s + x) % n;
            auto top = copy.top();
            copy.pop();
            auto next = make_pair(top.first + b[index]/2, top.second+1);
            maxValue = max(maxValue, next.second);
            copy.push(next);
        }
        //cout << s << "," << maxValue << endl;
        if(minValue > maxValue)
        {
            minValue = maxValue;
        }
    }
    cout << minValue << endl;
    return 0;
}
0