結果

問題 No.1736 Princess vs. Dragoness
ユーザー lloyzlloyz
提出日時 2021-11-12 22:26:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 1,024 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 10,796 KB
実行使用メモリ 8,668 KB
最終ジャッジ日時 2023-08-17 02:23:17
合計ジャッジ時間 2,505 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,236 KB
testcase_01 AC 16 ms
8,192 KB
testcase_02 AC 17 ms
8,244 KB
testcase_03 AC 18 ms
8,200 KB
testcase_04 AC 20 ms
8,228 KB
testcase_05 AC 17 ms
8,184 KB
testcase_06 AC 19 ms
8,556 KB
testcase_07 AC 23 ms
8,592 KB
testcase_08 AC 21 ms
8,328 KB
testcase_09 AC 21 ms
8,548 KB
testcase_10 AC 17 ms
8,192 KB
testcase_11 AC 22 ms
8,600 KB
testcase_12 AC 19 ms
8,256 KB
testcase_13 AC 20 ms
8,556 KB
testcase_14 AC 23 ms
8,660 KB
testcase_15 AC 18 ms
8,232 KB
testcase_16 AC 17 ms
8,304 KB
testcase_17 AC 22 ms
8,532 KB
testcase_18 AC 19 ms
8,416 KB
testcase_19 AC 20 ms
8,388 KB
testcase_20 AC 17 ms
8,248 KB
testcase_21 AC 20 ms
8,508 KB
testcase_22 AC 21 ms
8,668 KB
testcase_23 AC 17 ms
8,628 KB
testcase_24 AC 17 ms
8,256 KB
testcase_25 AC 18 ms
8,196 KB
testcase_26 AC 17 ms
8,224 KB
testcase_27 AC 18 ms
8,492 KB
testcase_28 AC 18 ms
8,404 KB
testcase_29 AC 17 ms
8,368 KB
testcase_30 AC 18 ms
8,420 KB
testcase_31 AC 19 ms
8,252 KB
testcase_32 AC 17 ms
8,204 KB
testcase_33 AC 17 ms
8,240 KB
testcase_34 AC 17 ms
8,184 KB
testcase_35 AC 16 ms
8,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, a, b, x, y = map(int, input().split())
H = list(map(int, input().split()))

for i in range(n):
    q, r = divmod(H[i], x)
    if a >= q:
        H[i] = r
        a -= q
    else:
        H[i] -= a * x
        a = 0
    if a == 0:
        break

if a > 0:
    Hc = [(H[i], i) for i in range(n)]
    Hc.sort(key=lambda x: x[0], reverse=True)
    for i in range(n):
        ind = Hc[i][1]
        if H[ind] > 0:
            a -= 1
            H[ind] = 0
        if a == 0:
            break

if b > 0:
    cy = y
    for i in range(n):
        if H[i] > cy:
            H[i] -= cy
            b -= 1
            if b == 0:
                break
            q, r = divmod(H[i], y)
            b -= q
            if b <= 0:
                break
            H[i] = 0
            cy = y - r
        else:
            cy -= H[i]
            H[i] = 0
            if cy == 0:
                b -= 1
                cy = y

if sum(H) == 0:
    print("Yes")
else:
    print("No")

0