結果
問題 | No.1194 Replace |
ユーザー |
![]() |
提出日時 | 2025-04-16 15:35:01 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 504 bytes |
コンパイル時間 | 589 ms |
コンパイル使用メモリ | 82,096 KB |
実行使用メモリ | 103,444 KB |
最終ジャッジ日時 | 2025-04-16 15:39:56 |
合計ジャッジ時間 | 9,996 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 WA * 21 |
ソースコード
n, m = map(int, input().split()) operations = [] for _ in range(m): b, c = map(int, input().split()) operations.append((b, c)) # Sort operations by C in descending order operations.sort(key=lambda x: -x[1]) max_map = {} for b, c in operations: current_b = max_map.get(b, b) current_c = max_map.get(c, c) if current_c > current_b: max_map[b] = current_c total = n * (n + 1) // 2 sum_diff = 0 for key in max_map: sum_diff += (max_map[key] - key) print(total + sum_diff)