結果
問題 | No.617 Nafmo、買い出しに行く |
ユーザー |
|
提出日時 | 2017-12-05 00:05:55 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 219 ms / 2,000 ms |
コード長 | 701 bytes |
コンパイル時間 | 3,703 ms |
コンパイル使用メモリ | 74,812 KB |
実行使用メモリ | 41,436 KB |
最終ジャッジ日時 | 2024-11-28 05:16:40 |
合計ジャッジ時間 | 8,267 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
package tmp;import java.util.Arrays;import java.util.Comparator;import java.util.Scanner;public class Main {public static void main(String[] args) {new Main().run();}void run() {Scanner sc = new Scanner(System.in);int N = sc.nextInt();int K = sc.nextInt();int[] A = new int[N];for (int i = 0; i < N; ++i) {A[i] = sc.nextInt();}int ans = 0;for (int s = 0; s < 1 << N; ++s) {int tmp = 0;for (int i = 0; i < N; ++i) {if ((s >> i) % 2 == 1) {tmp += A[i];}}if (tmp <= K) {ans = Math.max(ans, tmp);}}System.out.println(ans);}void tr(Object... objects) {System.out.println(Arrays.deepToString(objects));}}