結果

問題 No.1015 おつりは要らないです
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-06-15 15:49:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,024 bytes
コンパイル時間 432 ms
コンパイル使用メモリ 86,952 KB
実行使用メモリ 108,388 KB
最終ジャッジ日時 2023-08-27 06:48:28
合計ジャッジ時間 9,561 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,320 KB
testcase_01 AC 75 ms
71,560 KB
testcase_02 AC 75 ms
71,248 KB
testcase_03 AC 74 ms
71,256 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 75 ms
71,400 KB
testcase_08 AC 75 ms
71,280 KB
testcase_09 AC 75 ms
71,280 KB
testcase_10 AC 234 ms
105,640 KB
testcase_11 AC 223 ms
104,896 KB
testcase_12 AC 229 ms
107,784 KB
testcase_13 AC 225 ms
105,788 KB
testcase_14 AC 226 ms
104,456 KB
testcase_15 AC 203 ms
99,588 KB
testcase_16 AC 233 ms
107,584 KB
testcase_17 AC 226 ms
104,856 KB
testcase_18 AC 231 ms
107,736 KB
testcase_19 AC 231 ms
107,628 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 74 ms
71,408 KB
testcase_31 AC 138 ms
99,512 KB
testcase_32 AC 139 ms
99,684 KB
testcase_33 AC 159 ms
104,344 KB
testcase_34 AC 76 ms
71,316 KB
testcase_35 AC 75 ms
71,148 KB
testcase_36 AC 76 ms
71,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main1(n,x,y,z,a):
	b=[(u+1+1000-1)//1000 for u in a]
	# おつりありで支払うために千円札何枚必要か。
	# まず1万円札、5000円札で支払う部分を払う。
	for i in range(n):
		if b[i]>10 and z:
			tmp=min(z,b[i]//10)
			z-=tmp
			b[i]-=tmp*10
	if z>=n:return True
	for i in range(n):
		if b[i]>5 and y:
			tmp=min(y,b[i]//5)
			y-=tmp
			b[i]-=tmp*5
	if y>=n:return True

	# ピッタリの支払いにならないが、1万円札で支払う店を決める。
	c=[[10-u%10,i] for i,u in enumerate(b)]
	c.sort(key=lambda u:u[0])
	for u,i in c[:z]:
		b[i]=b[i]-b[i]%10
	z=0
	# ピッタリの支払いにならないが、5000円札で支払う店を決める。
	c=[[5-u%5,i] for i,u in enumerate(b)]
	c.sort(key=lambda u:u[0])
	for u,i in c[:y]:
		b[i]=b[i]-b[i]%5
	y=0
	# 残りは1000円札で払う
	if sum(b)<=x:return True
	return False

if __name__=='__main__':
	n,x,y,z=map(int,input().split())
	a=list(map(int,input().split()))
	ret1=main1(n,x,y,z,a)
	print('Yes' if ret1 else 'No')
0