結果

問題 No.9 モンスターのレベル上げ
ユーザー GOTKAKO
提出日時 2024-05-07 00:18:12
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 279 ms / 5,000 ms
コード長 753 bytes
コンパイル時間 2,197 ms
コンパイル使用メモリ 200,272 KB
最終ジャッジ日時 2025-02-21 11:31:14
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int N; cin >> N;
    vector<int> A(N),B(N);
    for(auto &a : A) cin >> a;
    for(auto &b : B) cin >> b;
    for(int i=0; i<N; i++) B.push_back(B.at(i));

    int answer = 1e9;
    for(int i=0; i<N; i++){
        int now = 0;
        priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>> Q;
        for(int k=0; k<N; k++) Q.push({A.at(k),0});
        for(int k=i; k<i+N; k++){
            auto[level,fight] = Q.top(); Q.pop();
            level += B.at(k)/2; fight++;
            now = max(fight,now); 
            Q.push({level,fight});  
        }
        answer = min(answer,now);
    }
    cout << answer << endl;
}
0