結果
問題 |
No.2093 Shio Ramen
|
ユーザー |
|
提出日時 | 2024-04-13 16:20:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 600 bytes |
コンパイル時間 | 4,306 ms |
コンパイル使用メモリ | 249,876 KB |
最終ジャッジ日時 | 2025-02-21 01:07:07 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll = long long; using ld = long double; using mint = modint998244353; int N, I, s[1010], a[1010]; int dp[1010][1010]; int main() { cin >> N >> I; for (int i = 0; i < N; i++) cin >> s[i] >> a[i]; for (int i = 0; i < N; i++) { for (int j = 0; j <= I; j++) { dp[i + 1][j] = dp[i][j]; if (j - s[i] >= 0) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - s[i]] + a[i]); } } int ans = 0; for (int j = 0; j <= I; j++) ans = max(ans, dp[N][j]); cout << ans << endl; return 0; }