結果
問題 | No.9 モンスターのレベル上げ |
ユーザー |
|
提出日時 | 2021-08-12 13:17:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 289 ms / 5,000 ms |
コード長 | 849 bytes |
コンパイル時間 | 1,958 ms |
コンパイル使用メモリ | 199,416 KB |
最終ジャッジ日時 | 2025-01-23 17:44:31 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:7:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | u64 N; scanf("%lu", &N); | ~~~~~^~~~~~~~~~~ main.cpp:9:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | for (u64 u = 0; u < N; u++) scanf("%lu", &a[u]); | ~~~~~^~~~~~~~~~~~~~ main.cpp:10:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | for (u64 u = 0; u < N; u++) scanf("%lu", &b[u]); | ~~~~~^~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> using u64 = std::uint64_t; int main() { std::cin.tie(0)->sync_with_stdio(false); u64 N; scanf("%lu", &N); std::vector<u64> a(N), b(N); for (u64 u = 0; u < N; u++) scanf("%lu", &a[u]); for (u64 u = 0; u < N; u++) scanf("%lu", &b[u]); u64 ans = 1234567890; for (u64 d = 0; d < N; d++) { std::priority_queue<std::pair<u64,u64>, std::vector<std::pair<u64,u64>>, std::greater<std::pair<u64,u64>>> pq; for (u64 j = 0; j < N; j++) pq.push({a[j], 0}); u64 idx = d; u64 MAX = 0; for (u64 j = 0; j < N; j++) { u64 exp = pq.top().first; u64 cnt = pq.top().second; pq.pop(); cnt++; MAX = std::max(MAX, cnt); exp += (b[idx++] / 2); pq.push({exp, cnt}); if (idx >= N) idx -=N; } ans = std::min(ans, MAX); } printf("%lu\n", ans); return 0; }