結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2016-06-10 22:00:53 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 52 ms / 5,000 ms |
コード長 | 838 bytes |
コンパイル時間 | 252 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 12,160 KB |
最終ジャッジ日時 | 2024-11-18 08:40:38 |
合計ジャッジ時間 | 2,723 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
def quick_sort(list): if len(list) < 1: return list pivot = list[0] left = [] right = [] for i in range(1, len(list)): if list[i] < pivot: left.append(list[i]) else: right.append(list[i]) left = quick_sort(left) right = quick_sort(right) foo = [pivot] return left + foo + right def list_convert_int(list): converted_list = [] for str in list: converted_list.append(int(str)) return converted_list def main(): L = int(input()) N = int(input()) width_list = input().split() sum_width = 0 count = 0 list = list_convert_int(width_list) sorted_width_list = quick_sort(list) for i in sorted_width_list: width = int (i) if sum_width + width > L: break else: sum_width += width count += 1 print(count) if __name__ == '__main__': main()