結果
| 問題 | No.37 遊園地のアトラクション |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-21 23:04:59 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 6 ms / 5,000 ms |
| + 284µs | |
| コード長 | 983 bytes |
| 記録 | |
| コンパイル時間 | 2,998 ms |
| コンパイル使用メモリ | 183,980 KB |
| 実行使用メモリ | 9,904 KB |
| 最終ジャッジ日時 | 2026-10-21 23:05:08 |
| 合計ジャッジ時間 | 3,953 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 27 |
ソースコード
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
using namespace std;
int t, n;
cin >> t >> n;
vector<int> C(n), V(n);
for (auto &e : C) { cin >> e; }
for (auto &e : V) { cin >> e; }
vector<pair<int, int>> attractions;
for (int i = 0; i < n; i++) {
while (V[i] > 0) {
attractions.emplace_back(C[i], V[i]);
V[i] /= 2;
}
}
n = attractions.size();
vector dp(n + 1, vector<int>(t + 1, -1));
dp[0][0] = 0;
for (int i = 0; i < n; i++) {
auto [c, v] = attractions[i];
for (int j = 0; j < t + 1; j++) {
if (dp[i][j] == -1) { continue; }
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
if (j + c <= t) {
dp[i + 1][j + c] = max(dp[i + 1][j + c], dp[i][j] + v);
}
}
}
int ans = 0;
for (int j = 0; j < t + 1; j++) {
ans = max(ans, dp[n][j]);
}
cout << ans << endl;
}