結果
問題 | No.844 split game |
ユーザー |
![]() |
提出日時 | 2025-03-31 17:42:29 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 232 ms / 2,000 ms |
コード長 | 1,327 bytes |
コンパイル時間 | 216 ms |
コンパイル使用メモリ | 82,060 KB |
実行使用メモリ | 118,464 KB |
最終ジャッジ日時 | 2025-03-31 17:43:41 |
合計ジャッジ時間 | 8,944 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 56 |
ソースコード
import sysfrom collections import defaultdictdef main():input = sys.stdin.read().split()ptr = 0N = int(input[ptr])ptr += 1M = int(input[ptr])ptr += 1A = int(input[ptr])ptr += 1groups = defaultdict(list)for _ in range(M):l = int(input[ptr])ptr += 1r = int(input[ptr])ptr += 1p = int(input[ptr])ptr += 1groups[r].append((l, p))dp = [-float('inf')] * (N + 1)dp[0] = 0global_max = dp[0]for i in range(1, N + 1):current_max = -float('inf')if i in groups:for (l, p) in groups[i]:j = l - 1if j < 0:continue # invalid jif dp[j] == -float('inf'):continuecurrent_val = dp[j] + pif current_val > current_max:current_max = current_valmax_part_a = current_max if current_max != -float('inf') else -float('inf')max_part_b = global_maxcandidate = max(max_part_a, max_part_b)if i < N:candidate -= Adp[i] = candidateif dp[i] > global_max:global_max = dp[i]result = max(dp[N], 0)print(result)if __name__ == "__main__":main()