結果

問題 No.2710 How many more?
ユーザー KeeKee
提出日時 2024-03-31 23:25:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 331 ms / 2,000 ms
コード長 1,247 bytes
コンパイル時間 229 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 86,540 KB
最終ジャッジ日時 2024-03-31 23:25:15
合計ジャッジ時間 5,775 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
55,608 KB
testcase_01 AC 44 ms
55,608 KB
testcase_02 AC 276 ms
81,700 KB
testcase_03 AC 212 ms
81,852 KB
testcase_04 AC 210 ms
86,204 KB
testcase_05 AC 172 ms
80,512 KB
testcase_06 AC 181 ms
84,032 KB
testcase_07 AC 179 ms
77,936 KB
testcase_08 AC 168 ms
78,636 KB
testcase_09 AC 255 ms
84,120 KB
testcase_10 AC 226 ms
80,728 KB
testcase_11 AC 233 ms
79,556 KB
testcase_12 AC 295 ms
85,284 KB
testcase_13 AC 308 ms
86,536 KB
testcase_14 AC 331 ms
86,536 KB
testcase_15 AC 302 ms
86,536 KB
testcase_16 AC 303 ms
86,540 KB
testcase_17 AC 304 ms
86,532 KB
testcase_18 AC 43 ms
55,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python3

import bisect
import collections
import heapq
import itertools
import math
import os
import sys


def main():
    n, q = read_ints()
    A = read_ints()
    B = [-a for a in A]
    B.sort()

    for _ in range(q):
        x, y = read_ints()
        x -= 1
        y -= 1
        i = bisect.bisect_right(B, -A[x])
        j = bisect.bisect_left(B, -A[y])
        if j - i > 0:
            print(j - i)
        else:
            print(0)


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

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def list2d(d1, d2, init=None):
    return [[init] * d2 for _ in range(d1)]


def list3d(d1, d2, d3, init=None):
    return [[[init] * d3 for _ in range(d2)] for _ in range(d1)]


def list4d(d1, d2, d3, d4, init=None):
    return [[[[init] * d4 for _ in range(d3)] for _ in range(d2)]
            for _ in range(d1)]


def debug(fmt, *args):
    if DEBUG:
        if args:
            print(fmt.format(*args), file=sys.stderr)
        else:
            print(fmt, file=sys.stderr)


if __name__ == '__main__':
    main()
0