結果

問題 No.5 数字のブロック
ユーザー 6soukiti29
提出日時 2017-07-05 19:42:55
言語 Nim
(2.2.0)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 320 bytes
コンパイル時間 3,167 ms
コンパイル使用メモリ 66,088 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-30 01:34:16
合計ジャッジ時間 4,312 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils,strutils,algorithm

var
    L = stdin.readline.parseInt
    N = stdin.readline.parseInt
    W = stdin.readline.split.map(parseInt)
    cnt,ans : int
W.sort(system.cmp)
cnt = 0
ans = -1
for i,w in W:
    cnt += w
    if cnt > L:
        ans = i
        break
if ans == -1:
    echo N
else:
    echo ans


0