結果
| 問題 | No.2710 How many more? | 
| コンテスト | |
| ユーザー |  lam6er | 
| 提出日時 | 2025-03-20 21:05:57 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 228 ms / 2,000 ms | 
| コード長 | 663 bytes | 
| コンパイル時間 | 249 ms | 
| コンパイル使用メモリ | 81,792 KB | 
| 実行使用メモリ | 125,416 KB | 
| 最終ジャッジ日時 | 2025-03-20 21:06:04 | 
| 合計ジャッジ時間 | 4,991 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 17 | 
ソースコード
import bisect
def main():
    import sys
    input = sys.stdin.read().split()
    ptr = 0
    N = int(input[ptr])
    ptr += 1
    Q = int(input[ptr])
    ptr += 1
    
    A = list(map(int, input[ptr:ptr+N]))
    ptr += N
    sorted_A = sorted(A)
    
    for _ in range(Q):
        x = int(input[ptr])
        ptr += 1
        y = int(input[ptr])
        ptr += 1
        
        a = A[x-1]
        b = A[y-1]
        
        if a <= b:
            print(0)
        else:
            left = bisect.bisect_right(sorted_A, b)
            right = bisect.bisect_left(sorted_A, a)
            print(right - left)
            
if __name__ == "__main__":
    main()
            
            
            
        