結果
問題 |
No.3302 Sense Battle
|
ユーザー |
![]() |
提出日時 | 2025-10-05 14:24:37 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 241 ms / 2,000 ms |
コード長 | 757 bytes |
コンパイル時間 | 954 ms |
コンパイル使用メモリ | 109,548 KB |
実行使用メモリ | 198,912 KB |
最終ジャッジ日時 | 2025-10-05 14:24:48 |
合計ジャッジ時間 | 4,687 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <set> using namespace std; int main() { int n; cin >> n; vector<vector<long long>> dp(n + 1, vector<long long> (n + 1, -1e18)); vector<int> a(n), b(n); for (int i = 0; i < n; ++i) cin >> a[i] >> b[i]; reverse(a.begin(), a.end()); reverse(b.begin(), b.end()); dp[0][0] = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + b[i]); for (int j = 0; j <= n; ++j) { dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + (long long)a[i] * j); } } long long ans = 0; for (int i = 0; i <= n; ++i) ans = max(ans, dp[n][i]); cout << ans << endl; }