結果
問題 |
No.1332 Range Nearest Query
|
ユーザー |
![]() |
提出日時 | 2021-01-08 22:48:49 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,013 bytes |
コンパイル時間 | 332 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 132,216 KB |
最終ジャッジ日時 | 2024-11-16 14:20:52 |
合計ジャッジ時間 | 44,711 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 48 |
ソースコード
import sys from bisect import bisect read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines INF = 1 << 60 def main(V, query): def merge(A, B): NA, NB = len(A), len(B) i, j = 0, 0 C = [] for _ in range(NA + NB): if i == NA: C.append(B[j]) j += 1 elif j == NB: C.append(A[i]) i += 1 else: if A[i] > B[j]: C.append(B[j]) j += 1 else: C.append(A[i]) i += 1 return C N = len(V) seg = [[] for _ in range(N + N)] for i in range(N): seg[N + i] = [V[i]] for i in range(N - 1, 0, -1): seg[i] = merge(seg[i + i], seg[i + i + 1]) N = int(readline()) X = tuple(map(int, readline().split())) Q = int(readline()) m = map(int, read().split()) query = tuple(zip(m, m, m)) main(X, query)