結果
| 問題 |
No.3302 Sense Battle
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-05 16:32:16 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 666 bytes |
| コンパイル時間 | 1,853 ms |
| コンパイル使用メモリ | 201,016 KB |
| 実行使用メモリ | 199,040 KB |
| 最終ジャッジ日時 | 2025-10-05 16:32:27 |
| 合計ジャッジ時間 | 10,617 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 RE * 5 |
ソースコード
#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));
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;
}