結果
問題 | No.2242 Cities and Teleporters |
ユーザー |
👑 |
提出日時 | 2024-04-28 14:55:52 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,533 ms / 3,000 ms |
コード長 | 894 bytes |
コンパイル時間 | 492 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 247,748 KB |
最終ジャッジ日時 | 2024-11-17 07:41:22 |
合計ジャッジ時間 | 30,857 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
52,224 KB |
testcase_01 | AC | 38 ms
52,096 KB |
testcase_02 | AC | 38 ms
51,712 KB |
testcase_03 | AC | 38 ms
52,480 KB |
testcase_04 | AC | 40 ms
52,608 KB |
testcase_05 | AC | 1,063 ms
220,192 KB |
testcase_06 | AC | 994 ms
205,056 KB |
testcase_07 | AC | 1,049 ms
197,064 KB |
testcase_08 | AC | 1,322 ms
200,136 KB |
testcase_09 | AC | 1,271 ms
196,784 KB |
testcase_10 | AC | 1,038 ms
233,980 KB |
testcase_11 | AC | 1,285 ms
236,252 KB |
testcase_12 | AC | 1,140 ms
235,724 KB |
testcase_13 | AC | 1,340 ms
233,672 KB |
testcase_14 | AC | 1,316 ms
236,800 KB |
testcase_15 | AC | 1,204 ms
236,736 KB |
testcase_16 | AC | 1,440 ms
236,656 KB |
testcase_17 | AC | 1,533 ms
232,776 KB |
testcase_18 | AC | 1,236 ms
238,872 KB |
testcase_19 | AC | 1,325 ms
240,808 KB |
testcase_20 | AC | 1,178 ms
226,968 KB |
testcase_21 | AC | 1,170 ms
247,748 KB |
testcase_22 | AC | 1,306 ms
247,428 KB |
testcase_23 | AC | 1,360 ms
233,464 KB |
testcase_24 | AC | 1,382 ms
233,412 KB |
testcase_25 | AC | 1,340 ms
233,552 KB |
ソースコード
n = int(input()) H = list(map(int, input().split())) T = list(map(int, input().split())) X = H + T X = sorted(set(X)) dic = {X[i]: i for i in range(len(X))} H = [dic[h] for h in H] T = [dic[t] for t in T] le = len(X) m = 20 nex = [[i for i in range(le)] for _ in range(m)] for h, t in zip(H, T): nex[0][h] = max(nex[0][h], t) for i in range(1, le): nex[0][i] = max(nex[0][i], nex[0][i - 1]) for i in range(1, m): for j in range(le): nex[i][j] = nex[i - 1][nex[i - 1][j]] Q = int(input()) for _ in range(Q): a, b = map(int, input().split()) a -= 1 b -= 1 if T[a] >= H[b]: print(1) continue ans = 1 t = T[a] for i in range(m - 1, -1, -1): nt = nex[i][t] if nt < H[b]: t = nt ans += 1 << i ans += 1 nt = nex[0][t] if nt >= H[b]: print(ans) else: print(-1)