結果
問題 |
No.9 モンスターのレベル上げ
|
ユーザー |
![]() |
提出日時 | 2025-09-05 12:17:04 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 164 ms / 5,000 ms |
コード長 | 1,499 bytes |
コンパイル時間 | 989 ms |
コンパイル使用メモリ | 105,828 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-05 12:17:08 |
合計ジャッジ時間 | 3,203 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
#include <iostream> #include <iomanip> #include <queue> #include <vector> #include <utility> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10); int N; cin >> N; int A[1500]; int B[1500]; // Read array A for (int i = 0; i < N; i++) { cin >> A[i]; } // Read array B and halve each value for (int i = 0; i < N; i++) { cin >> B[i]; B[i] /= 2; } int answer = N; for (int m = 0; m < N; m++) { priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> tasks; // Initialize tasks with A values and zero count for (int i = 0; i < N; i++) { tasks.push(make_pair(A[i], 0)); } int max_count = 0; for (int k = 0; k < N; k++) { auto current = tasks.top(); tasks.pop(); int new_value = current.first + B[(m + k) % N]; int new_count = current.second + 1; tasks.push(make_pair(new_value, new_count)); if (new_count > max_count) { max_count = new_count; if (answer <= max_count) { break; } } } if (answer > max_count) { answer = max_count; } } cout << answer << endl; return 0; }