結果

問題 No.2710 How many more?
ユーザー yaakiyuyaakiyu
提出日時 2024-03-31 15:23:24
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,964 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 122,368 KB
最終ジャッジ日時 2024-03-31 15:23:31
合計ジャッジ時間 6,877 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 395 ms
103,260 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 192 ms
77,240 KB
testcase_08 AC 178 ms
82,300 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 287 ms
87,904 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 36 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# competetive programming
# 競プロにつかえるもの

# sys関連
import sys
#sys.setrecursionlimit(100000000)
if sys.version_info.minor >= 11:
    # python3.11以上でのみ4300桁制限がかかる
    sys.set_int_max_str_digits(10000000)

#input = lambda: sys.stdin.readline()[:-1]

### import関連
## もしpypyなら
#import pypyjit; pypyjit.set_param('max_unroll_recursion=-1')  # 再帰関数の展開をする
#from atcoder.dsu import DSU  # UnionFind 使い方:uf=DSU(頂点数) ; uf.merge(u, v) ; uf.same(u, v) ; uf.leader(u) ; uf.size(u) ; uf.groups()
#from atcoder.scc import SCCGraph # SCC 使い方:g=SCCGraph(頂点数) ; g.add_edge(u, v) ; scc=g.scc()
#from atcoder.segtree import SegTree # セグ木 使い方:tree=SegTree(関数, 単位元, 元リスト) ; tree.set(pos, x) ; tree.prod(left, right + 1) # 閉区間
#import heapq # Priority Queue 使い方:q=[...] ; heapq.heapify(q) ; heapq.heappush(q, item) ; heapq.heappop(q, item)
#from collections import deque  # Queue 使い方:q=deque(lis) ; q.popleft(item) ; q.append(item)
#from collections import Counter # Counter
#from collections import defaultdict # defaultdict delに注意
#from itertools import accumulate # 累積和
#from itertools import combinations # 組み合わせ
#from bisect import bisect_left, bisect_right # 二分探索
#from decimal import Decimal, getcontext; getcontext().prec = 100 # 正確な少数

### 定数関連
#inf = float("inf")
#inf = 10**18
#mod = 998244353
#mod = 1000000007 # 10**9+7
#dir = ((0, 1), (1, 0), (0, -1), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)) # 8近傍 4まで回せば4近傍

INTIN = lambda: int(input())
def MAPIN(kansu=int):
    return map(kansu, input().split())
LISTIN = lambda k=int: list(MAPIN(k))

n, q = MAPIN()
a = LISTIN()
# 座圧して引き算
a_new = sorted(set(a))
a_new = {v: i for i, v in enumerate(a_new)}

for i in range(q):
	x, y = MAPIN()
	print(max(0, (a_new[a[x-1]]-a_new[a[y-1]]-1)))
0