結果
問題 |
No.617 Nafmo、買い出しに行く
|
ユーザー |
![]() |
提出日時 | 2020-09-07 14:16:30 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 178 ms / 2,000 ms |
コード長 | 592 bytes |
コンパイル時間 | 2,855 ms |
コンパイル使用メモリ | 84,256 KB |
実行使用メモリ | 56,460 KB |
最終ジャッジ日時 | 2024-11-29 10:42:50 |
合計ジャッジ時間 | 6,668 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); boolean[] sums = new boolean[k + 1]; sums[0] = true; for (int i = 0; i < n; i++) { int x = sc.nextInt(); for (int j = k - x; j >= 0; j--) { if (sums[j]) { sums[j + x] = true; } } } for (int i = k; i >= 0; i--) { if (sums[i]) { System.out.println(i); return; } } } }