結果

問題 No.617 Nafmo、買い出しに行く
ユーザー toshiro_yanagi
提出日時 2018-06-16 01:31:34
言語 Nim
(2.2.0)
結果
WA  
実行時間 -
コード長 365 bytes
コンパイル時間 3,786 ms
コンパイル使用メモリ 65,800 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-30 15:52:08
合計ジャッジ時間 4,710 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 13 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, sequtils, algorithm

var
  A = newSeq[int]()
  i, cnt, best = 0
let
  NK = stdin.readLine.split.map parseInt
  (N, K) = (NK[0], NK[1])

for i in 0 ..< N:
  A.add stdin.readLine.parseInt

A.sort(cmp, Descending)
while i < A.len:
  cnt += A[i]
  if cnt <= K:
    i += 1
    best = max(cnt, best)
  else:
    i = 0
    cnt = 0
    A.del(0)

echo best
0