結果

問題 No.3302 Sense Battle
ユーザー olff
提出日時 2025-10-06 22:23:54
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 191 ms / 2,000 ms
コード長 672 bytes
コンパイル時間 3,033 ms
コンパイル使用メモリ 281,256 KB
実行使用メモリ 198,912 KB
最終ジャッジ日時 2025-10-06 22:24:02
合計ジャッジ時間 7,037 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const ll MOD = 998244353;
const int INF = 2e9;
const ll LINF = 2e18;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = { 0, 1, 0,-1};

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; (i) < (n); (i)++)
#define rep1(i, n) for (int i = 1; (i) < ((n) + 1); (i)++)

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int N;
  cin>>N;
  vector<ll> A(N), B(N);
  rep(i,N){
    cin>>A[i]>>B[i];
  }

  vector<vector<ll>> dp(N+1,vector<ll>(N+1,0));
  rep(i,N){
    rep(j,N){
      dp[i+1][j] = max(dp[i][j]+A[i]*j, dp[i][j+1]+B[i]);
    }
  }

  cout<<dp[N][0]<<endl;
}
0