結果

問題 No.1726 [Cherry 3rd Tune B] ジャマイカビアポン
ユーザー tamatotamato
提出日時 2021-10-29 21:52:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,506 ms / 3,000 ms
コード長 1,045 bytes
コンパイル時間 335 ms
コンパイル使用メモリ 82,508 KB
実行使用メモリ 345,708 KB
最終ジャッジ日時 2024-10-07 11:01:28
合計ジャッジ時間 21,204 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9
K = 10 ** 10


def main():
    import sys
    input = sys.stdin.readline

    def solve(AB, CD, P):
        N = len(AB)
        M = len(CD)
        S = {}
        for i in range(N):
            a, b = AB[i]
            p = P[i]
            for j in range(M):
                c, d = CD[j]
                hsh = (a - c) * K + (b - d)
                if hsh not in S:
                    S[hsh] = 0
                S[hsh] += p
        res = 0
        for s in S:
            res = max(res, S[s])
        return res

    N, M = map(int, input().split())
    P = list(map(int, input().split()))
    AB = []
    CD = []
    for _ in range(N):
        AB.append(tuple(map(int, input().split())))
    for _ in range(M):
        CD.append(tuple(map(int, input().split())))
    AB1 = [(-a, b) for a, b in AB]
    AB2 = [(a, -b) for a, b in AB]
    AB3 = [(-a, -b) for a, b in AB]

    ans = max(solve(AB, CD, P), solve(AB1, CD, P), solve(AB2, CD, P), solve(AB3, CD, P))
    print(ans)


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