結果
問題 | No.2093 Shio Ramen |
ユーザー |
|
提出日時 | 2022-10-07 21:33:06 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 37 ms / 2,000 ms |
コード長 | 906 bytes |
コンパイル時間 | 816 ms |
コンパイル使用メモリ | 115,160 KB |
実行使用メモリ | 19,712 KB |
最終ジャッジ日時 | 2024-06-12 06:20:51 |
合計ジャッジ時間 | 2,675 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 30 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(int n) => Enumerable.Repeat(0, n).Select(_ => NList).ToArray(); static void Main() { Solve(); } static void Solve() { var c = NList; var (n, x) = (c[0], c[1]); var map = NArr(n); var dp = new int[x + 1]; for (var i = 0; i < n; ++i) { for (var j = x; j >= 0; --j) { if (j > 0 && dp[j] == 0) continue; if (j + map[i][0] >= dp.Length) continue; dp[j + map[i][0]] = Math.Max(dp[j + map[i][0]], dp[j] + map[i][1]); } } WriteLine(dp.Max()); } }