結果

問題 No.5 数字のブロック
ユーザー yoza
提出日時 2016-12-11 03:08:05
言語 Vim script
(v9.1)
結果
AC  
実行時間 81 ms / 5,000 ms
コード長 613 bytes
コンパイル時間 218 ms
コンパイル使用メモリ 6,820 KB
実行使用メモリ 12,720 KB
最終ジャッジ日時 2024-11-18 10:47:59
合計ジャッジ時間 3,129 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

function! s:output()
  let this = {'lines': []}

  function! this.append(line) abort
    call add(self.lines, a:line)
  endfunction

  function! this.build() abort
    return join(self.lines, "\n")
  endfunction

  return this
endfunction

function! s:main(input) abort
  let o = s:output()

  let l = str2nr(a:input[0])
  let w_list = map(split(a:input[2], ' '), 'str2nr(v:val)')
  let c = 0
  for w in sort(w_list, 'n')
    let l -= w
    if l < 0
      break
    endif
    let c += 1
  endfor

  call o.append(c)
  return o.build()
endfunction

let s:input = getline(1, '$')
enew
put =s:main(s:input)
2,$print
0