結果

問題 No.2375 watasou and hibit's baseball
ユーザー NP
提出日時 2023-07-08 09:03:57
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 897 bytes
コンパイル時間 379 ms
コンパイル使用メモリ 82,332 KB
実行使用メモリ 85,304 KB
最終ジャッジ日時 2024-07-22 04:52:38
合計ジャッジ時間 3,969 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other TLE * 1 -- * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import permutations

def max_balls(N, A, B, balls):
    max_count = 0
    for perm in permutations(range(N)):
        count = 1
        for i in range(1, N):
            if i == 1:
                if abs(balls[perm[i]][0] - balls[perm[i-1]][0]) + abs(balls[perm[i]][1] - balls[perm[i-1]][1]) >= A:
                    count += 1
            elif i >= 2:
                if abs(balls[perm[i]][2] - balls[perm[i-1]][2]) >= B or abs(balls[perm[i]][0] - balls[perm[i-1]][0]) + abs(balls[perm[i]][1] - balls[perm[i-1]][1]) + abs(balls[perm[i]][0] - balls[perm[i-2]][0]) + abs(balls[perm[i]][1] - balls[perm[i-2]][1]) >= A:
                    count += 1
        max_count = max(max_count, count)
    return max_count

N, A, B = map(int, input().split())
balls = []
for _ in range(N):
    x, y, k = map(int, input().split())
    balls.append((x, y, k))

print(max_balls(N, A, B, balls))

0