結果
問題 |
No.3302 Sense Battle
|
ユーザー |
|
提出日時 | 2025-10-05 14:47:21 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 62 ms / 2,000 ms |
コード長 | 598 bytes |
コンパイル時間 | 3,010 ms |
コンパイル使用メモリ | 278,936 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-10-05 14:47:27 |
合計ジャッジ時間 | 4,285 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll =long long; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); ll N; cin>>N; vector<ll> DP(N+1,-1e18); vector<ll> A(N),B(N); for(int i=0;i<N;i++){ cin>>A[i]>>B[i]; } DP[0]=0; for(int i=N-1;i>=0;i--){ vector<ll> NDP(N+1,-1e18); for(int j=0;j<=N;j++){ if(j!=N)NDP[j+1]=max(NDP[j+1],DP[j]+B[i]); NDP[j]=max(NDP[j],DP[j]+A[i]*j); } swap(DP,NDP); } ll an=0; for(int i=0;i<=N;i++)an=max(an,DP[i]); cout<<an<<"\n"; }