結果
問題 |
No.596 郵便配達
|
ユーザー |
![]() |
提出日時 | 2025-06-12 15:40:39 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,088 bytes |
コンパイル時間 | 160 ms |
コンパイル使用メモリ | 82,456 KB |
実行使用メモリ | 183,224 KB |
最終ジャッジ日時 | 2025-06-12 15:40:45 |
合計ジャッジ時間 | 4,630 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 WA * 10 |
ソースコード
def main(): import sys input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]) ptr += 1 M = int(input[ptr]) ptr += 1 min_x = float('inf') max_x = -float('inf') min_y = float('inf') max_y = -float('inf') for _ in range(M): x_i = int(input[ptr]) ptr += 1 d_i = int(input[ptr]) ptr += 1 if x_i < min_x: min_x = x_i if x_i > max_x: max_x = x_i for __ in range(d_i): y_j = int(input[ptr]) ptr += 1 if y_j < min_y: min_y = y_j if y_j > max_y: max_y = y_j # Calculate the total distance part1 = max_x - min_x part2 = max_y - min_y # Compute the minimal connection between the two parts connections = [ abs(max_x - min_y), abs(max_x - max_y), abs(min_x - min_y), abs(min_x - max_y) ] min_connection = min(connections) total = part1 + part2 + min_connection print(total) if __name__ == "__main__": main()