結果
| 問題 |
No.2093 Shio Ramen
|
| コンテスト | |
| ユーザー |
nyya
|
| 提出日時 | 2022-10-07 21:53:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 1,016 bytes |
| コンパイル時間 | 3,390 ms |
| コンパイル使用メモリ | 232,892 KB |
| 実行使用メモリ | 11,392 KB |
| 最終ジャッジ日時 | 2024-06-12 07:08:06 |
| 合計ジャッジ時間 | 4,307 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
//using mint = modint;
using mint = modint998244353;
using P = pair<int, int>;
const ll INF=1LL<<60, dx[]={0,1,0,-1},dy[]={1,0,-1,0};
bool chmin(ll& a,ll b){if(a>b){a=b; return 1;} return 0;}
bool chmax(ll& a,ll b){if(a<b){a=b; return 1;} return 0;}
int main(){
int n,maxi;
cin >> n >> maxi;
vector<int> s(n),a(n);
rep(i,n) cin >> s[i] >> a[i];
vector<vector<ll>> dp(n+1,vector<ll> (maxi+1,-INF));
dp[0][0]=0;
for(int i=1;i<=n;i++){
rep(j,maxi+1){
if(j-s[i-1]>=0) dp[i][j]=max(dp[i-1][j-s[i-1]]+a[i-1],dp[i-1][j]);
else dp[i][j]=dp[i-1][j];
}
}
/*
rep(i,n+1){
rep(j,maxi+1) {
cout << i << " " << j << " " << dp[i][j] << endl;
}
}
*/
ll ans = 0;
rep(i,maxi+1) chmax(ans,dp[n][i]);
cout << ans << endl;
return 0;
}
nyya