結果
| 問題 |
No.2093 Shio Ramen
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2022-10-07 23:22:27 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 771 bytes |
| コンパイル時間 | 304 ms |
| コンパイル使用メモリ | 42,184 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-12 21:24:48 |
| 合計ジャッジ時間 | 1,389 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 30 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 2093.cc: No.2093 Shio Ramen - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 1000;
const int MAX_S = 1000;
/* typedef */
/* global variables */
int ss[MAX_N], as[MAX_N];
int dp[MAX_S + 1];
/* subroutines */
inline void setmax(int &a, int b) { if (a < b) a = b; }
/* main */
int main() {
int n, s;
scanf("%d%d", &n, &s);
for (int i = 0; i < n; i++) scanf("%d%d", ss + i , as + i);
fill(dp, dp + s + 1, -1);
dp[0] = 0;
for (int i = 0; i < n; i++)
for (int j = s - ss[i]; j >= 0; j--)
if (dp[j] >= 0)
setmax(dp[j + ss[i]], dp[j] + as[i]);
int maxd = 0;
for (int j = 0; j <= s; j++) setmax(maxd, dp[j]);
printf("%d\n", maxd);
return 0;
}
tnakao0123