結果

問題 No.2710 How many more?
ユーザー kemunikukemuniku
提出日時 2024-03-31 14:11:26
言語 Nim
(2.0.2)
結果
AC  
実行時間 201 ms / 2,000 ms
コード長 3,693 bytes
コンパイル時間 4,111 ms
コンパイル使用メモリ 76,188 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-09-30 19:06:57
合計ジャッジ時間 7,050 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,820 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 170 ms
6,820 KB
testcase_03 AC 100 ms
6,816 KB
testcase_04 AC 75 ms
6,816 KB
testcase_05 AC 58 ms
6,816 KB
testcase_06 AC 64 ms
6,816 KB
testcase_07 AC 78 ms
6,816 KB
testcase_08 AC 53 ms
6,816 KB
testcase_09 AC 142 ms
6,820 KB
testcase_10 AC 83 ms
6,816 KB
testcase_11 AC 135 ms
6,820 KB
testcase_12 AC 185 ms
6,816 KB
testcase_13 AC 199 ms
6,816 KB
testcase_14 AC 197 ms
6,816 KB
testcase_15 AC 199 ms
6,820 KB
testcase_16 AC 197 ms
6,816 KB
testcase_17 AC 201 ms
6,820 KB
testcase_18 AC 1 ms
6,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import macros;macro ImportExpand(s:untyped):untyped = parseStmt($s[2])
import macros
ImportExpand "cplib/tmpl/sheep.nim" <=== "when not declared CPLIB_TMPL_SHEEP:\n    const CPLIB_TMPL_SHEEP* = 1\n    {.warning[UnusedImport]: off.}\n    {.hint[XDeclaredButNotUsed]: off.}\n    import algorithm\n    import sequtils\n    import tables\n    import macros\n    import math\n    import sets\n    import strutils\n    import strformat\n    import sugar\n    import heapqueue\n    import streams\n    import deques\n    import bitops\n    import std/lenientops\n    import options\n    #入力系\n    proc scanf(formatstr: cstring){.header: \"<stdio.h>\", varargs.}\n    proc getchar(): char {.importc: \"getchar_unlocked\", header: \"<stdio.h>\", discardable.}\n    proc ii(): int {.inline.} = scanf(\"%lld\\n\", addr result)\n    proc lii(N: int): seq[int] {.inline.} = newSeqWith(N, ii())\n    proc si(): string {.inline.} =\n        result = \"\"\n        var c: char\n        while true:\n            c = getchar()\n            if c == ' ' or c == '\\n':\n                break\n            result &= c\n    #chmin,chmax\n    template `max=`(x, y) = x = max(x, y)\n    template `min=`(x, y) = x = min(x, y)\n    #bit演算\n    proc `%`(x: int, y: int): int = (((x mod y)+y) mod y)\n    proc `//`(x: int, y: int): int = (((x) - (x%y)) div (y))\n    proc `%=`(x: var int, y: int): void = x = x%y\n    proc `//=`(x: var int, y: int): void = x = x//y\n    proc `**`(x: int, y: int): int = x^y\n    proc `**=`(x: var int, y: int): void = x = x^y\n    proc `^`(x: int, y: int): int = x xor y\n    proc `|`(x: int, y: int): int = x or y\n    proc `&`(x: int, y: int): int = x and y\n    proc `>>`(x: int, y: int): int = x shr y\n    proc `<<`(x: int, y: int): int = x shl y\n    proc `~`(x: int): int = not x\n    proc `^=`(x: var int, y: int): void = x = x ^ y\n    proc `&=`(x: var int, y: int): void = x = x & y\n    proc `|=`(x: var int, y: int): void = x = x | y\n    proc `>>=`(x: var int, y: int): void = x = x >> y\n    proc `<<=`(x: var int, y: int): void = x = x << y\n    proc `[]`(x: int, n: int): bool = (x and (1 shl n)) != 0\n    #便利な変換\n    proc `!`(x: char, a = '0'): int = int(x)-int(a)\n    #定数\n    const INF = int(3300300300300300491)\n    #converter\n\n    #range\n    iterator range(start: int, ends: int, step: int): int =\n        var i = start\n        if step < 0:\n            while i > ends:\n                yield i\n                i += step\n        elif step > 0:\n            while i < ends:\n                yield i\n                i += step\n    iterator range(ends: int): int = (for i in 0..<ends: yield i)\n    iterator range(start: int, ends: int): int = (for i in\n            start..<ends: yield i)\n"
ImportExpand "cplib/math/powmod.nim" <=== "when not declared CPLIB_MATH_POWMOD:\n    const CPLIB_MATH_POWMOD* = 1\n    #[ import cplib/math/inner_math ]#\n    when not declared CPLIB_MATH_INNER_MATH:\n        const CPLIB_MATH_INNER_MATH* = 1\n        proc add*(a, b, m: int): int {.importcpp: \"((__int128)(#) + (__int128)(#)) % (__int128)(#)\", nodecl.}\n        proc mul*(a, b, m: int): int {.importcpp: \"(__int128)(#) * (__int128)(#) % (__int128)(#)\", nodecl.}\n    proc powmod*(a, n, m: int): int =\n        var\n            rev = 1\n            a = a\n            n = n\n        while n > 0:\n            if n mod 2 != 0: rev = mul(rev, a, m)\n            if n > 1: a = mul(a, a, m)\n            n = n shr 1\n        return rev\n"
var N,Q = ii()
var A = lii(N).mapit(10**11-it)
var X = A.sorted()
for _ in range(Q):
    var x,y = ii()-1
    if A[x] >= A[y]:
        echo 0
    else:
        echo X.lowerBound(A[y])-X.upperBound(A[x])
0