結果

問題 No.617 Nafmo、買い出しに行く
ユーザー letrangerjpletrangerjp
提出日時 2017-12-17 00:32:26
言語 Ruby
(3.3.0)
結果
AC  
実行時間 352 ms / 2,000 ms
コード長 154 bytes
コンパイル時間 420 ms
コンパイル使用メモリ 11,460 KB
実行使用メモリ 17,276 KB
最終ジャッジ日時 2023-08-21 11:44:30
合計ジャッジ時間 5,607 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,084 KB
testcase_01 AC 77 ms
15,148 KB
testcase_02 AC 78 ms
15,392 KB
testcase_03 AC 96 ms
17,188 KB
testcase_04 AC 77 ms
15,024 KB
testcase_05 AC 113 ms
17,256 KB
testcase_06 AC 347 ms
17,192 KB
testcase_07 AC 352 ms
17,116 KB
testcase_08 AC 81 ms
15,292 KB
testcase_09 AC 79 ms
15,276 KB
testcase_10 AC 346 ms
17,020 KB
testcase_11 AC 346 ms
17,112 KB
testcase_12 AC 345 ms
17,276 KB
testcase_13 AC 342 ms
17,064 KB
testcase_14 AC 340 ms
17,168 KB
testcase_15 AC 336 ms
17,260 KB
testcase_16 AC 338 ms
17,152 KB
testcase_17 AC 338 ms
17,140 KB
testcase_18 AC 78 ms
15,176 KB
testcase_19 AC 79 ms
15,108 KB
testcase_20 AC 81 ms
15,152 KB
testcase_21 AC 78 ms
15,156 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, K = gets.split.map &:to_i
A = $<.map &:to_i

ans = 0
(0..N).each{|i|
  A.combination(i){|a|
    n = a.sum
    ans = n if n <= K && n > ans
  }
}
p ans
0