結果
| 問題 | No.1015 おつりは要らないです |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-10 22:48:39 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,568 bytes |
| 記録 | |
| コンパイル時間 | 413 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 21,720 KB |
| 最終ジャッジ日時 | 2024-09-15 23:05:04 |
| 合計ジャッジ時間 | 15,233 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 2 |
| other | AC * 28 WA * 5 |
ソースコード
N, sen, gosen, man = map(int, input().split())
A = list(map(int, input().split()))
def calc(a):
if sen * 1000 + gosen * 5000 + man * 10000 <= a:
return (-1, -1, -1)
x = a
m = min(man, x // 10000)
x -= m * 10000
g = min(gosen, x // 5000)
x -= g * 5000
s = min(sen, x // 1000)
x -= s * 1000
if x < 1000 and sen - s > 0:
return (s + 1, g, m)
if x < 5000 and gosen - g > 0:
x -= 5000
while x + 1000 < 0 and s > 0:
x += 1000
s -= 1
return (s, g + 1, m)
x -= 10000
while x + 5000 < 0 and g > 0:
x += 5000
g -= 1
while x + 1000 < 0 and s > 0:
x += 1000
s -= 1
return (s, g, m + 1)
def diff(a):
x, y, z = calc(a)
return 1000 * x + y * 5000 + z * 10000 - a >= 1000
A.sort(key=lambda a: diff(a) - a, reverse=True)
while A and sen > 0:
a = A[-1]
x, y, z = calc(a)
if 1000 * x + y * 5000 + z * 10000 - a >= 1000:
break
A.pop()
if x == -1:
print('No')
exit()
sen -= x
gosen -= y
man -= z
A.sort(key=lambda a: diff(a) - a, reverse=True)
while A and gosen > 0:
a = A[-1]
x, y, z = calc(a)
if 1000 * x + y * 5000 + z * 10000 - a >= 5000:
break
A.pop()
if x == -1:
print('No')
exit()
sen -= x
gosen -= y
man -= z
A.sort(reverse=True)
while A and gosen > 0:
a = A.pop()
x, y, z = calc(a)
if x == -1:
print('No')
exit()
sen -= x
gosen -= y
man -= z
print('Yes')