結果
| 問題 | 
                            No.2710 How many more?
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2024-03-31 15:12:06 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 437 bytes | 
| コンパイル時間 | 372 ms | 
| コンパイル使用メモリ | 82,364 KB | 
| 実行使用メモリ | 113,044 KB | 
| 最終ジャッジ日時 | 2024-09-30 20:22:47 | 
| 合計ジャッジ時間 | 6,535 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 6 WA * 11 | 
ソースコード
# coding: utf-8
# Your code here!
from collections import defaultdict
num=defaultdict(int)
d = defaultdict(int)
n,q=map(int,input().split())
a=list(map(int,input().split()))
for i,x in enumerate(a):
    num[i+1]=x
#print(num[1])
a.sort()
d[0]=0
for i in range(n):
    d[a[i]]=i+1
 
#print(d)
for i in range(q):
    x,y=map(int,input().split())
    x2,y2=num[x],num[y]
    #print(x2,y2)
    print(d[x2]-d[y2]-1 if d[x2]>d[y2] else 0)