結果

問題 No.9 モンスターのレベル上げ
ユーザー troro_kelptroro_kelp
提出日時 2018-12-30 23:16:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 417 ms / 5,000 ms
コード長 1,415 bytes
コンパイル時間 878 ms
コンパイル使用メモリ 100,552 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 13:54:20
合計ジャッジ時間 5,319 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 417 ms
5,376 KB
testcase_03 AC 347 ms
5,376 KB
testcase_04 AC 182 ms
5,376 KB
testcase_05 AC 119 ms
5,376 KB
testcase_06 AC 41 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 51 ms
5,376 KB
testcase_09 AC 415 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 324 ms
5,376 KB
testcase_12 AC 257 ms
5,376 KB
testcase_13 AC 199 ms
5,376 KB
testcase_14 AC 407 ms
5,376 KB
testcase_15 AC 370 ms
5,376 KB
testcase_16 AC 7 ms
5,376 KB
testcase_17 AC 243 ms
5,376 KB
testcase_18 AC 207 ms
5,376 KB
testcase_19 AC 5 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;

int A[1510], B[1510];

bool operator<(const pair<int, int> &a, const pair<int, int> &b)
{
    if (a.first == b.first)
        return a.second < b.second;
    return a.first < b.first;
};
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
int main(void)
{
    int N;
    cin >> N;

    for (int i = 0; i < N; ++i)
    {
        cin >> A[i];
        pq.push(make_pair(A[i], 0));
    }
    for (int i = 0; i < N; ++i)
        cin >> B[i];

    int ans = 100000;

    for (int i = 0; i < N; ++i)
    {
        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq2 = pq;
        int idx = 0;

        while (idx != N)
        {
            pair<int, int> p = pq2.top();
            pq2.pop();
            p.first += B[(i + idx) % N] / 2;
            p.second += 1;
            pq2.push(p);
            idx++;
        }

        int maxV = 0;
        while (pq2.size())
        {
            pair<int, int> p = pq2.top();
            pq2.pop();
            maxV = max(maxV, p.second);
        }
        ans = min(ans, maxV);
    }
    cout << ans << endl;
    return 0;
}
0