結果
| 問題 | No.3302 Sense Battle | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-10-10 13:28:12 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 38 ms / 2,000 ms | 
| コード長 | 714 bytes | 
| コンパイル時間 | 2,016 ms | 
| コンパイル使用メモリ | 198,104 KB | 
| 実行使用メモリ | 7,716 KB | 
| 最終ジャッジ日時 | 2025-10-10 13:28:16 | 
| 合計ジャッジ時間 | 4,020 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 18 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, l, r) for (ll i = (l); i < (r); ++i)
#define RFOR(i, l, r) for (ll i = (r) - 1; (l) <= i; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
using VLL = vector<ll>;
using VP = vector<pair<ll,ll>>;
static const ll INF = (1LL << 62) - 1;  // 4611686018427387904 - 1
int main() {
  ll N;
  cin >> N;
  VP AB(N);
  REP(i, N) { cin >> AB[i].first >> AB[i].second; }
  VLL dp(N+1,-INF);
  dp[0] = 0;
  RREP(i, N) {
    auto [a, b] = AB[i];
    RREP(n, N) {
      dp[n+1] = max(dp[n+1], dp[n]+b);
      dp[n] = max(dp[n], dp[n]+a*n);
    }
  }
  ll ans = 0;
  REP(n, N+1) ans = max(ans, dp[n]);
  cout << ans << endl;
}
            
            
            
        