結果

問題 No.1015 おつりは要らないです
ユーザー ouoz1Vouoz1V
提出日時 2020-04-12 16:57:57
言語 Nim
(2.0.2)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 1,062 bytes
コンパイル時間 4,244 ms
コンパイル使用メモリ 70,080 KB
実行使用メモリ 8,528 KB
最終ジャッジ日時 2023-08-11 12:44:25
合計ジャッジ時間 8,085 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 100 ms
7,108 KB
testcase_11 AC 101 ms
7,272 KB
testcase_12 AC 95 ms
7,020 KB
testcase_13 AC 99 ms
7,056 KB
testcase_14 AC 104 ms
7,264 KB
testcase_15 AC 96 ms
6,992 KB
testcase_16 AC 99 ms
7,116 KB
testcase_17 AC 101 ms
7,120 KB
testcase_18 AC 98 ms
7,048 KB
testcase_19 AC 98 ms
7,024 KB
testcase_20 AC 98 ms
7,012 KB
testcase_21 AC 98 ms
7,096 KB
testcase_22 AC 97 ms
7,048 KB
testcase_23 AC 93 ms
6,964 KB
testcase_24 AC 99 ms
7,152 KB
testcase_25 AC 97 ms
7,044 KB
testcase_26 AC 96 ms
7,152 KB
testcase_27 AC 96 ms
6,948 KB
testcase_28 AC 96 ms
6,980 KB
testcase_29 AC 98 ms
7,148 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 36 ms
6,780 KB
testcase_32 AC 36 ms
6,916 KB
testcase_33 AC 40 ms
8,528 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 2 ms
4,380 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