結果

問題 No.9 モンスターのレベル上げ
ユーザー firiexp
提出日時 2023-03-17 12:53:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 444 ms / 5,000 ms
コード長 1,187 bytes
コンパイル時間 846 ms
コンパイル使用メモリ 106,652 KB
最終ジャッジ日時 2025-02-11 12:15:11
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:27:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 |     for (auto &&i : a) scanf("%d", &i);
      |                        ~~~~~^~~~~~~~~~
main.cpp:29:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   29 |         scanf("%d", &b[i]);
      |         ~~~~~^~~~~~~~~~~~~

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
#include <limits>

static const int MOD = 998244353;
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(2*n);
    for (auto &&i : a) scanf("%d", &i);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &b[i]);
        b[i+n] = b[i];
    }


    int ans = INF<int>;
    for (int i = 0; i < n; ++i) {
        GPQ<pair<int, int>> Q;
        for (int j = 0; j < n; ++j) {
            Q.emplace(a[j], 0);
        }
        for (int k = 0; k < n; ++k) {
            auto p = Q.top(); Q.pop();
            p.first += b[i+k]/2;
            p.second++;
            Q.emplace(p);
        }
        int w = 0;
        while(!Q.empty()){
            w = max(w, Q.top().second); Q.pop();
        }
        ans = min(ans, w);
    }
    cout << ans << "\n";
    return 0;
}
0