結果
| 問題 |
No.2093 Shio Ramen
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-30 16:22:26 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 10 ms / 2,000 ms |
| コード長 | 737 bytes |
| コンパイル時間 | 22,992 ms |
| コンパイル使用メモリ | 355,976 KB |
| 最終ジャッジ日時 | 2025-02-20 15:56:07 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 30 |
ソースコード
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
void IO(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
}
int main(){
IO();
ll n,I;
cin>>n>>I;
vector<ll> s(n),a(n);
for(ll i=0;i<n;i++){
cin>>s[i]>>a[i];
}
vector<vector<ll>> dp(n+1,vector<ll>(I+1,-1e18));
dp[0][0]=0;
for(ll i=0;i<n;i++){
for(ll j=0;j<=I;j++){
if(j+s[i]<=I){
dp[i+1][j+s[i]]=max(dp[i+1][j+s[i]],dp[i][j]+a[i]);
}
dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
}
}
ll ans=-1e18;
for(ll i=0;i<=I;i++){
ans=max(ans,dp[n][i]);
}
cout<<ans<<endl;
}