結果
問題 |
No.206 数の積集合を求めるクエリ
|
ユーザー |
![]() |
提出日時 | 2025-05-14 12:51:52 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 775 bytes |
コンパイル時間 | 387 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 115,584 KB |
最終ジャッジ日時 | 2025-05-14 12:53:18 |
合計ジャッジ時間 | 11,640 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 TLE * 1 -- * 6 |
ソースコード
import bisect def main(): import sys input = sys.stdin.read().split() ptr = 0 L = int(input[ptr]) ptr += 1 M = int(input[ptr]) ptr += 1 N = int(input[ptr]) ptr += 1 A = list(map(int, input[ptr:ptr+L])) ptr += L B = list(map(int, input[ptr:ptr+M])) ptr += M Q = int(input[ptr]) ptr += 1 B_sorted = sorted(B) cnt = [0] * Q for x in A: min_y = x - (Q - 1) max_y = x left = bisect.bisect_left(B_sorted, min_y) right = bisect.bisect_right(B_sorted, max_y) for y in B_sorted[left:right]: v = x - y if 0 <= v < Q: cnt[v] += 1 for v in range(Q): print(cnt[v]) if __name__ == '__main__': main()