結果

問題 No.1015 おつりは要らないです
ユーザー いた
提出日時 2025-01-07 23:39:51
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 690 bytes
コンパイル時間 521 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 184,192 KB
最終ジャッジ日時 2025-01-07 23:40:32
合計ジャッジ時間 41,493 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 TLE * 1
other AC * 13 WA * 9 TLE * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

N,X,Y,Z=map(int,input().split())
A=[0]+list(map(int,input().split()))


for i in range(1,N+1):
  A[i]+=A[i-1]
for i in reversed(range(1,N+1)):
  now=A[i]-A[i-1]
  A.pop()
  if Z>now//10000:
    Z-=now//10000
    now%=10000
  else:
    now-=10000*Z
    Z=0
  if Y>now//5000:
    Y-=now//5000
    now%=5000
  else:
    now-=5000*Y
    Y=0
  while now>-1 and (X or Y or Z):
    if Y and X*1000+(Y-1)*5000+Z*10000>=A[-1]:
      now-=5000
      Y-=1
    elif Z and X*1000+Y*5000+(Z-1)*10000>=A[-1]:
      now-=10000
      Z-=1
    else:
      X-=-(-now//1000)
      now-=(-(-now//1000*1000))
      if now==0:
        X-=1
  if X<0 or Y<0 or Z<0 or now>-1:
    print("No")
    exit()
print("Yes")
0