結果

問題 No.1517 Party Location
ユーザー soraie_soraie_
提出日時 2021-05-28 20:25:03
言語 Nim
(2.0.2)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 3,641 bytes
コンパイル時間 4,106 ms
コンパイル使用メモリ 96,256 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-11 10:50:30
合計ジャッジ時間 4,674 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

{. warning[UnusedImport]:off .}
import sequtils,algorithm,math,tables,sets,strutils,times,pegs,macros,strformat,typetraits,terminal,os
proc scanf(formatstr: cstring){.header: "<stdio.h>", varargs.}
proc getchar(): char {.header: "<stdio.h>", varargs.}
proc ri*(): int = scanf("%lld",addr result)
proc rf*(): float = scanf("%lf",addr result)
proc rs*(): string =
    var get = false
    result = ""
    while true:
        var c = getchar()
        if int(c) > int(' '):
            get = true
            result.add(c)
        else:
            if get: break
            get = false
proc chmin*(a:var int,b:int): bool {.discardable.} =
    if a > b:
        a = b
        return true
    else:
        return false
proc chmax*(a:var int,b:int): bool {.discardable.} =
    if a < b:
        a = b
        return true
    else:
        return false
macro debug*(n: varargs[untyped]): untyped =
    var buff = fmt"""
when defined(debug):
    stderr.writeLine ("[debug] ---------------------------------")
"""
    var maxLen = 0
    for x in n:
        if x.kind == nnkIdent:
            let l = ($x).len
            if l > maxLen:
                maxLen = l
    for x in n:
        if x.kind == nnkStrLit:
            buff = buff & fmt"""
    stderr.writeLine ("[debug] - - - - - - - - - - - - - - - - -")
    stderr.writeLine ("[debug] " & {repr(x)})
    stderr.writeLine ("[debug] - - - - - - - - - - - - - - - - -")
"""
        if x.kind == nnkIdent:
            let name = " ".repeat(maxLen - ($x).len) & $x
            buff = buff & fmt"""
    stderr.writeLine ("[debug] {name} => " & ${repr(x)})
"""
    buff = buff & """
    stderr.writeLine ("[debug] ---------------------------------")
"""
    parseStmt(buff)

iterator range*(st,en: int): int =
    for idx in st..<en:
        yield idx
iterator range*(en: int): int =
    for idx in 0..<en:
        yield idx
iterator range*(st,en,step: int): int =
    var idx = st
    if st < en:
        doAssert step > 0
        while idx < en:
            yield idx
            idx += step
    else:
        doAssert step < 0
        while idx > en:
            yield idx
            idx += step
#

proc `%`*(x,y: SomeInteger): SomeInteger = x mod y
proc `//`*(x,y: SomeInteger): SomeInteger = x div y
proc `%=`*(x: var SomeInteger,y: SomeInteger) = x = x mod y
proc `/=`*(x: var SomeInteger,y: int) = x = x div y
proc `cd`*[T](x,y: T): T = x div y + ord(x mod y != 0)
when NimMajor <= 0 and NimMinor <= 18: import future else: import sugar
 
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

when defined release: {.checks: off.}

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

template countIt*[T](a: openArray[T]; pred: untyped): int =
    var result = 0
    for it {.inject.} in items(a):
        if pred: result.inc
    result

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

template newSeqWithImpl[T](lens: seq[int]; init: T; currentDimension, lensLen: static[int]): untyped =
    when currentDimension == lensLen:
        newSeqWith(lens[currentDimension - 1], init)
    else:
        newSeqWith(lens[currentDimension - 1], newSeqWithImpl(lens, init, currentDimension + 1, lensLen))

template newSeqWith*[T](lens: varargs[int]; init: T): untyped =
    assert(lens.allIt(it > 0))
    newSeqWithImpl(@lens, init, 1, lens.len)

template vector*[T](lens: varargs[int]; init: T = 0): untyped =
    assert(lens.allIt(it > 0))
    newSeqWithImpl(@lens, init, 1, lens.len)

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #


let d,a,b = ri()

echo min((a - b) * 0 + b * d,(a - b) * d + b * d)
0