結果
| 問題 |
No.2093 Shio Ramen
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-27 19:51:52 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 2,000 ms |
| コード長 | 979 bytes |
| コンパイル時間 | 1,628 ms |
| コンパイル使用メモリ | 170,508 KB |
| 実行使用メモリ | 7,552 KB |
| 最終ジャッジ日時 | 2024-07-05 05:11:28 |
| 合計ジャッジ時間 | 2,863 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 30 |
ソースコード
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
using LL = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
const long long LINF = 1LL << 60;
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); ++i)
template<class T>void chmin(T&a, T b){if(a > b) a = b;}
template<class T>void chmax(T&a, T b){if(a < b) a = b;}
int N, I;
int S[1009], A[1009];
int main(){
cin >> N >> I;
for(int i = 1; i <= N; ++i) cin >> S[i] >> A[i];
int INF = 1<<30;
vector<vector<int>> dp(N+1, vector<int>(I+1, -INF));
dp[0][0] = 0;
for(int i = 1; i <= N; ++i){
for(int j = 0; j <= I; ++j){
if(j>=S[i]) chmax(dp[i][j], dp[i-1][j-S[i]]+A[i]);
chmax(dp[i][j], dp[i-1][j]);
}
}
int ans = 0;
for(int i = 0; i <= I; ++i) ans = max(ans, dp[N][i]);
cout << ans << endl;
/*
for(int i = 0; i <= N; ++i){
for(int j = 0; j <= I; ++j){
cout << dp[i][j] << " ";
}
cout << endl;
}
*/
}