結果

問題 No.206 数の積集合を求めるクエリ
ユーザー rpy3cpprpy3cpp
提出日時 2015-05-09 00:51:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 823 bytes
コンパイル時間 467 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 28,088 KB
最終ジャッジ日時 2023-09-19 09:09:36
合計ジャッジ時間 11,575 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,872 KB
testcase_01 AC 16 ms
7,772 KB
testcase_02 AC 17 ms
7,860 KB
testcase_03 AC 17 ms
7,976 KB
testcase_04 AC 17 ms
7,948 KB
testcase_05 AC 17 ms
7,784 KB
testcase_06 AC 18 ms
8,304 KB
testcase_07 AC 18 ms
8,512 KB
testcase_08 AC 18 ms
8,664 KB
testcase_09 AC 18 ms
8,496 KB
testcase_10 AC 16 ms
7,780 KB
testcase_11 AC 17 ms
7,832 KB
testcase_12 AC 672 ms
8,544 KB
testcase_13 AC 364 ms
8,488 KB
testcase_14 AC 242 ms
8,540 KB
testcase_15 AC 20 ms
8,548 KB
testcase_16 AC 20 ms
8,720 KB
testcase_17 AC 85 ms
23,552 KB
testcase_18 AC 51 ms
16,488 KB
testcase_19 AC 78 ms
22,016 KB
testcase_20 AC 50 ms
19,668 KB
testcase_21 AC 58 ms
17,712 KB
testcase_22 AC 59 ms
18,424 KB
testcase_23 AC 79 ms
22,496 KB
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def read_data():
    L, M, N = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    Q = int(input())
    return L, M, N, A, B, Q

def solve(L, M, N, A, B, Q):
    if Q == 1:
        As = [False] * (N + 1)
        for ai in A:
            As[ai] = True
        counter = 0
        for bi in B:
            if As[bi]:
                counter += 1
        return [counter]
    A.sort()
    B.sort()
    counter = [0] * Q
    for bi in B:
        for ai in A:
            dif = ai - bi
            if dif < 0:
                continue
            if dif >= Q:
                break
            counter[dif] += 1
    return counter

if __name__ == '__main__':
    L, M, N, A, B, Q = read_data()
    counter = solve(L, M, N, A, B, Q)
    for c in counter:
        print(c)
0