結果

問題 No.156 キャンディー・ボックス
ユーザー pluto77pluto77
提出日時 2016-02-10 11:17:18
言語 Python2
(2.7.18)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 350 bytes
コンパイル時間 40 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2024-07-05 15:47:05
合計ジャッジ時間 1,120 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#coding: utf-8
##yuki_113
import sys

nm=[]
nm=map(int,raw_input().split())
n=nm[0]
m=nm[1]

c=[]
c=map(int,raw_input().split())
c.sort()

csum=sum(c)
if csum==0:
 print 0
 sys.exit()
if csum<m:
 print "The number of candy is insufficient"
 sys.exit()

s=0
for i in xrange(len(c)):
 s+=c[i]
 if s==m:
  print i+1
  break
 elif s>m:
  print i
  break
0