結果

問題 No.5 数字のブロック
ユーザー 初見わこつです
提出日時 2015-09-12 17:58:28
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 691 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 11,648 KB
最終ジャッジ日時 2024-07-19 06:18:21
合計ジャッジ時間 1,927 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python3

# This problem is http://yukicoder.me/problems/14

first_line  = input()
second_line = input()
third_line  = input()

max_width = int(first_line)
number_of_blocks = int(second_line)
width_blocks_of_indevidual = list(map(int, third_line.split(' ')))

width_blocks_ordered_by_asc = sorted(width_blocks_of_indevidual)

sum_width = 0
for block_index in range(number_of_blocks):
    sum_width += width_blocks_ordered_by_asc[block_index]
    if sum_width > max_width:
        print(block_index)
        break
if sum(width_blocks_ordered_by_asc) == max_width:
    print(len(width_blocks_ordered_by_asc))

# print(width_blocks_of_indevidual)
# print(width_blocks_ordered_by_asc)
0