結果
| 問題 | No.2710 How many more? |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-10 15:27:21 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 468 ms / 2,000 ms |
| コード長 | 434 bytes |
| 記録 | |
| コンパイル時間 | 358 ms |
| コンパイル使用メモリ | 85,376 KB |
| 実行使用メモリ | 102,272 KB |
| 最終ジャッジ日時 | 2026-04-19 01:29:04 |
| 合計ジャッジ時間 | 8,990 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 17 |
ソースコード
from bisect import bisect_left, bisect_right
def main():
N, Q = map(int, input().split())
A = list(map(int, input().split()))
A_sorted = sorted(map(lambda elm: -elm, A))
for _ in range(Q):
x, y = map(lambda n: int(n) - 1, input().split())
idx_x = bisect_right(A_sorted, -A[x])
idx_y = bisect_left(A_sorted, -A[y])
print(max(0, idx_y - idx_x))
if __name__ == "__main__":
main()