結果

問題 No.1015 おつりは要らないです
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-06-15 15:59:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 256 ms / 2,000 ms
コード長 1,195 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 109,144 KB
最終ジャッジ日時 2023-08-27 06:56:42
合計ジャッジ時間 8,786 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
72,352 KB
testcase_01 AC 97 ms
71,896 KB
testcase_02 AC 95 ms
72,252 KB
testcase_03 AC 94 ms
72,128 KB
testcase_04 AC 94 ms
72,036 KB
testcase_05 AC 93 ms
72,304 KB
testcase_06 AC 93 ms
72,316 KB
testcase_07 AC 93 ms
72,308 KB
testcase_08 AC 94 ms
72,156 KB
testcase_09 AC 92 ms
72,304 KB
testcase_10 AC 246 ms
106,420 KB
testcase_11 AC 252 ms
104,068 KB
testcase_12 AC 256 ms
109,144 KB
testcase_13 AC 249 ms
105,416 KB
testcase_14 AC 249 ms
104,452 KB
testcase_15 AC 248 ms
108,544 KB
testcase_16 AC 253 ms
108,252 KB
testcase_17 AC 251 ms
109,012 KB
testcase_18 AC 253 ms
108,404 KB
testcase_19 AC 253 ms
108,624 KB
testcase_20 AC 225 ms
108,468 KB
testcase_21 AC 232 ms
108,632 KB
testcase_22 AC 238 ms
108,452 KB
testcase_23 AC 226 ms
108,876 KB
testcase_24 AC 227 ms
108,048 KB
testcase_25 AC 224 ms
108,444 KB
testcase_26 AC 225 ms
108,432 KB
testcase_27 AC 225 ms
108,780 KB
testcase_28 AC 227 ms
108,408 KB
testcase_29 AC 227 ms
108,616 KB
testcase_30 AC 93 ms
72,360 KB
testcase_31 AC 176 ms
105,896 KB
testcase_32 AC 175 ms
105,688 KB
testcase_33 AC 179 ms
105,052 KB
testcase_34 AC 94 ms
72,036 KB
testcase_35 AC 93 ms
71,948 KB
testcase_36 AC 95 ms
72,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main0(n,x,y,z,a):
	pass

def main1(n,x,y,z,a):
	b=[(u+1+1000-1)//1000 for u in a]
	# おつりありで支払うために千円札何枚必要か。
	# まず1万円札、5000円札で支払う部分を払う。
	# 1万円札で払ってもロスがない店
	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
	# 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円札で払ってもロスがない店
	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
	# 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')

from random import randint
if __name__=='__main__1':
	for _ in range(100):
		n=randint(1,10)
		x=randint(1,10)
0