結果
| 問題 |
No.3302 Sense Battle
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-05 16:32:40 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 197 ms / 2,000 ms |
| コード長 | 668 bytes |
| コンパイル時間 | 1,979 ms |
| コンパイル使用メモリ | 201,168 KB |
| 実行使用メモリ | 199,168 KB |
| 最終ジャッジ日時 | 2025-10-05 16:32:46 |
| 合計ジャッジ時間 | 5,517 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
int main() {
lint n;
cin >> n;
vector<vector<lint>> dp(n+1, vector<lint>(n+1, -1));
vector<lint> 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 (lint i = 0; i < n; i++) {
for (lint j = 0; j < n; j++) {
if (dp[i][j] == -1) continue;
// a
dp[i+1][j] = max(dp[i+1][j], dp[i][j]+j*a[i]);
// b
dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+b[i]);
}
}
lint ans = 0;
for (int j = 0; j <= n; j++) {
ans = max(ans, dp[n][j]);
}
cout << ans << endl;
}