結果
問題 |
No.596 郵便配達
|
ユーザー |
![]() |
提出日時 | 2025-06-12 13:15:43 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 899 bytes |
コンパイル時間 | 202 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 189,784 KB |
最終ジャッジ日時 | 2025-06-12 13:18:10 |
合計ジャッジ時間 | 5,437 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 8 WA * 15 |
ソースコード
import sys def main(): input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]) ptr += 1 M = int(input[ptr]) ptr += 1 max_x = -1 min_x = N all_y = [] for _ in range(M): x_i = int(input[ptr]) ptr += 1 d_i = int(input[ptr]) ptr += 1 ys = list(map(int, input[ptr:ptr+d_i])) ptr += d_i # Update max_x and min_x for postboxes if x_i > max_x: max_x = x_i if x_i < min_x: min_x = x_i # Collect all destinations all_y.extend(ys) if not all_y: print(0) return max_y = max(all_y) min_y = min(all_y) part1 = max_x - min_x part2 = max_y - min_y part3 = max(0, max_x - max_y) part4 = max(0, min_y - min_x) total = part1 + part2 + part3 + part4 print(total) if __name__ == "__main__": main()