結果
問題 | No.2242 Cities and Teleporters |
ユーザー |
![]() |
提出日時 | 2023-03-08 16:57:33 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 904 bytes |
コンパイル時間 | 195 ms |
コンパイル使用メモリ | 82,528 KB |
実行使用メモリ | 186,152 KB |
最終ジャッジ日時 | 2024-09-18 03:29:07 |
合計ジャッジ時間 | 30,747 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 36 ms
53,728 KB |
testcase_01 | AC | 35 ms
53,272 KB |
testcase_02 | AC | 36 ms
53,664 KB |
testcase_03 | AC | 37 ms
53,076 KB |
testcase_04 | WA | - |
testcase_05 | AC | 1,259 ms
164,908 KB |
testcase_06 | AC | 1,491 ms
184,460 KB |
testcase_07 | AC | 1,394 ms
186,152 KB |
testcase_08 | AC | 1,497 ms
185,764 KB |
testcase_09 | AC | 1,407 ms
185,400 KB |
testcase_10 | AC | 903 ms
186,148 KB |
testcase_11 | AC | 1,147 ms
185,812 KB |
testcase_12 | AC | 1,249 ms
185,636 KB |
testcase_13 | AC | 1,250 ms
185,580 KB |
testcase_14 | AC | 1,510 ms
185,776 KB |
testcase_15 | AC | 1,219 ms
186,088 KB |
testcase_16 | AC | 1,314 ms
185,572 KB |
testcase_17 | AC | 1,771 ms
184,988 KB |
testcase_18 | AC | 1,159 ms
184,496 KB |
testcase_19 | AC | 1,326 ms
184,960 KB |
testcase_20 | AC | 1,360 ms
182,896 KB |
testcase_21 | AC | 1,180 ms
183,560 KB |
testcase_22 | AC | 1,321 ms
182,712 KB |
testcase_23 | AC | 1,365 ms
186,060 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
ソースコード
import bisect n = int(input()) h = list(map(int,input().split())) t = list(map(int,input().split())) g = [(h[i] << 31) + (1 << 30) - t[i] for i in range(n)] g.sort() hs = [g[i] >> 31 for i in range(n)] ts = [(1 << 30) - (g[i] & ((1 << 31) - 1)) for i in range(n)] dp = [[0] * n for i in range(30)] tmp = 0 for i in range(n): tmp = max(tmp, ts[i]) dp[0][i] = bisect.bisect_right(hs, tmp) - 1 for i in range(29): for j in range(n): if dp[i][j] >= 0: dp[i+1][j] = max(dp[i][j], dp[i][dp[i][j]]) else: dp[i+1][j] = -1 #print(dp) q = int(input()) for i in range(q): a, b = map(int,input().split()) a -= 1 b -= 1 f = 1 r = bisect.bisect_right(hs, t[a]) - 1 if r == -1: print(-1) continue if hs[r] >= h[b]: print(1) continue for j in range(29,-1,-1): if dp[j][r] >= 0 and hs[dp[j][r]] < h[b]: f += 2 ** j r = dp[j][r] if f >= n + 1: print(-1) else: print(f + 1)