結果

問題 No.1726 [Cherry 3rd Tune B] ジャマイカビアポン
ユーザー lam6er
提出日時 2025-03-31 17:50:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,109 ms / 3,000 ms
コード長 1,029 bytes
コンパイル時間 229 ms
コンパイル使用メモリ 82,220 KB
実行使用メモリ 355,232 KB
最終ジャッジ日時 2025-03-31 17:51:03
合計ジャッジ時間 18,480 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import defaultdict

def main():
    input = sys.stdin.read().split()
    idx = 0
    N, M = int(input[idx]), int(input[idx+1])
    idx += 2
    P = list(map(int, input[idx:idx+N]))
    idx += N
    cups = []
    for _ in range(N):
        a, b = int(input[idx]), int(input[idx+1])
        cups.append((a, b))
        idx += 2
    balls = []
    for _ in range(M):
        c, d = int(input[idx]), int(input[idx+1])
        balls.append((c, d))
        idx += 2

    sign_pairs = [(1, 1), (1, -1), (-1, 1), (-1, -1)]
    max_total = 0

    for s_x, s_y in sign_pairs:
        delta_sum = defaultdict(int)
        for (cj, dj) in balls:
            for i in range(N):
                ai, bi = cups[i]
                dx = cj - s_x * ai
                dy = dj - s_y * bi
                delta_sum[(dx, dy)] += P[i]
        current_max = max(delta_sum.values(), default=0)
        if current_max > max_total:
            max_total = current_max

    print(max_total)

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