結果
問題 | No.2710 How many more? |
ユーザー | player |
提出日時 | 2024-04-04 15:55:44 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 914 bytes |
コンパイル時間 | 355 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 107,776 KB |
最終ジャッジ日時 | 2024-04-04 15:55:53 |
合計ジャッジ時間 | 9,003 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
55,596 KB |
testcase_01 | AC | 41 ms
55,596 KB |
testcase_02 | AC | 507 ms
105,708 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 286 ms
98,816 KB |
testcase_06 | WA | - |
testcase_07 | AC | 205 ms
77,604 KB |
testcase_08 | AC | 211 ms
83,828 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 361 ms
89,488 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 41 ms
55,596 KB |
ソースコード
from collections import * n, q = map(int, input().split()) a = list(map(int, input().split())) b = [None] * n d = defaultdict(int) pl = defaultdict(int) for i in range(n): b[i] = (a[i], i) d[i] = a[i] pl[a[i]] += 1 b.sort() # ゼッケンiが全体で前から何番目か ans = [None] * n flg = False # print(pl) for i in range(n): di, p = b[i] # print(di, p) if i == 0: ans[p] = 0 former = p else: if d[former] == di: ans[p] = ans[former] flg = True else: if not flg: ans[p] = ans[former] + 1 else: ans[p] = ans[former] + pl[d[former]] flg = False former = p # print(ans) for _ in range(q): x, y = map(int, input().split()) x, y = x - 1, y - 1 num = ans[x] - ans[y] - 1 if num < 0: print(0) else: print(num)