結果
問題 |
No.617 Nafmo、買い出しに行く
|
ユーザー |
![]() |
提出日時 | 2018-02-28 18:21:42 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 535 bytes |
コンパイル時間 | 2,039 ms |
コンパイル使用メモリ | 75,344 KB |
実行使用メモリ | 54,484 KB |
最終ジャッジ日時 | 2024-12-21 13:55:40 |
合計ジャッジ時間 | 6,034 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 16 WA * 4 |
ソースコード
import java.util.*; import static java.lang.System.*; public class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int n = sc.nextInt(); int limit = sc.nextInt(); int[] ar = new int[n]; int max = Integer.MIN_VALUE; int temp; for (int i=0; i<n; i++) { ar[i] = sc.nextInt(); } for (int i=1; i<(1<<n); i++) { temp = 0; for (int j=0; j<n; j++) { if ((1&i>>j)==1) {temp += ar[j];} } if (temp <= limit) {max = Math.max(max,temp);} } out.println(max); } }