結果

問題 No.1015 おつりは要らないです
ユーザー ouoz1Vouoz1V
提出日時 2020-04-12 16:57:57
言語 Nim
(2.0.2)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 1,062 bytes
コンパイル時間 5,012 ms
コンパイル使用メモリ 74,624 KB
実行使用メモリ 7,552 KB
最終ジャッジ日時 2024-04-29 05:09:47
合計ジャッジ時間 8,174 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 90 ms
7,424 KB
testcase_11 AC 92 ms
7,424 KB
testcase_12 AC 86 ms
6,016 KB
testcase_13 AC 91 ms
7,424 KB
testcase_14 AC 95 ms
7,424 KB
testcase_15 AC 88 ms
7,424 KB
testcase_16 AC 90 ms
7,424 KB
testcase_17 AC 93 ms
7,424 KB
testcase_18 AC 89 ms
7,552 KB
testcase_19 AC 89 ms
7,424 KB
testcase_20 AC 88 ms
6,272 KB
testcase_21 AC 87 ms
6,144 KB
testcase_22 AC 87 ms
6,144 KB
testcase_23 AC 84 ms
6,144 KB
testcase_24 AC 89 ms
6,144 KB
testcase_25 AC 88 ms
6,144 KB
testcase_26 AC 87 ms
6,144 KB
testcase_27 AC 86 ms
6,144 KB
testcase_28 AC 85 ms
6,144 KB
testcase_29 AC 87 ms
6,144 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 27 ms
5,376 KB
testcase_32 AC 26 ms
5,376 KB
testcase_33 AC 32 ms
7,424 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 45) Warning: Use the new 'sugar' module instead; future is deprecated [Deprecated]
/home/judge/data/code/Main.nim(1, 75) Warning: imported and not used: 'intsets' [UnusedImport]
/home/judge/data/code/Main.nim(1, 84) Warning: imported and not used: 'deques' [UnusedImport]
/home/judge/data/code/Main.nim(1, 53) Warning: imported and not used: 'sets' [UnusedImport]
/home/judge/data/code/Main.nim(1, 39) Warning: imported and not used: 'math' [UnusedImport]
/home/judge/data/code/Main.nim(1, 45) Warning: imported and not used: 'future' [UnusedImport]

ソースコード

diff #

import sequtils, strutils, algorithm, math, future, sets, tables, hashes, intsets, deques
let read = iterator : string {.closure.} = (while true: (for s in stdin.readLine.split : yield s))


var
    n,x,y,z = read().parseint
    a = newseqwith(n, read().parseint + 1)
    maisu = {1000: x, 5000: y, 10000: z}.toTable

proc calc(satsu: int) = 
    a.sort(Descending)
    for i in 0 ..< n:
        var
            cur = a[i]
        if a[i] >= satsu:
            a[i] -= min(maisu[satsu] * satsu, a[i] div satsu * satsu)
            maisu[satsu] = max(0, maisu[satsu] - (cur - a[i]) div satsu)
        if maisu[satsu] == 0:
            break
    a.sort(Descending)
    for i in 0 ..< n:
        var
            cur = a[i]
        if a[i] > 0:
            a[i] -= min(maisu[satsu] * satsu, (a[i] + satsu - 1) div satsu * satsu)
            maisu[satsu] = max(0, maisu[satsu] - (cur - a[i] + satsu - 1) div satsu)
        if maisu[satsu] == 0:
            break

calc(10000)
calc(5000)
calc(1000)

if a.filterit(it > 0).len != 0:
    echo "No"
else:
    echo "Yes"

0