結果

問題 No.206 数の積集合を求めるクエリ
ユーザー qwewe
提出日時 2025-05-14 12:51:55
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 747 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 82,244 KB
実行使用メモリ 124,364 KB
最終ジャッジ日時 2025-05-14 12:53:39
合計ジャッジ時間 11,137 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 TLE * 1 -- * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

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

    A.sort()
    B.sort()

    ans = [0] * Q

    for x in A:
        lower = x - (Q - 1)
        upper = x
        left = bisect.bisect_left(B, lower)
        right = bisect.bisect_right(B, upper)
        for i in range(left, right):
            b = B[i]
            v = x - b
            if 0 <= v < Q:
                ans[v] += 1

    for a in ans:
        print(a)

if __name__ == '__main__':
    main()
0