結果
問題 |
No.1015 おつりは要らないです
|
ユーザー |
![]() |
提出日時 | 2020-04-04 11:06:10 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 91 ms / 2,000 ms |
コード長 | 1,144 bytes |
コンパイル時間 | 290 ms |
コンパイル使用メモリ | 81,880 KB |
実行使用メモリ | 89,280 KB |
最終ジャッジ日時 | 2024-11-18 05:44:49 |
合計ジャッジ時間 | 3,856 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
n,z,y,x= map(int, input().split()) a= list(map(int, input().split())) a.sort(reverse=True) # 1万円以上のものには、1万円を割り当てる for i in range(n): if a[i]//10000>=1 and a[i]//10000<=x: x-=a[i]//10000 a[i]%=10000 elif a[i]//10000>x and x>0: a[i]-=10000*x x=0 break else: break a.sort(reverse=True) # 1万円を値段の高いもの順に割り当てる if x>0: # すでに1万円以上はない if n<=x: print('Yes') exit() else: del a[:x] # 5000円以上のものに50000円を割り当てる。 n1=len(a) for i in range(n1): if a[i]//5000==0: break elif a[i]//5000<=y: y-=a[i]//5000 a[i] %= 5000 elif a[i]//5000>y and y>0: a[i]-=5000*y y=0 else: break a.sort(reverse=True) # すでに5000円以上はない if y>0: if n1<=y: print('Yes') exit() else: del a[:y] # 1000円以上のものに1000円を割り当てる n2=len(a) for i in range(n2): z-=a[i]//1000+1 if z>=0: print('Yes') else: print('No')