結果
| 問題 | No.617 Nafmo、買い出しに行く |
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2020-09-07 14:16:30 |
| 言語 | Java (openjdk 27 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 127 ms / 2,000 ms |
| + 333µs | |
| コード長 | 592 bytes |
| 記録 | |
| コンパイル時間 | 3,274 ms |
| コンパイル使用メモリ | 85,140 KB |
| 実行使用メモリ | 49,128 KB |
| 最終ジャッジ日時 | 2026-10-01 23:29:02 |
| 合計ジャッジ時間 | 7,341 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}
}
}
}
tenten