結果
問題 |
No.561 東京と京都
|
ユーザー |
|
提出日時 | 2025-09-03 17:17:14 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 67 ms / 2,000 ms |
コード長 | 1,266 bytes |
コンパイル時間 | 316 ms |
コンパイル使用メモリ | 82,500 KB |
実行使用メモリ | 67,884 KB |
最終ジャッジ日時 | 2025-09-03 17:17:17 |
合計ジャッジ時間 | 3,009 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 17 |
ソースコード
from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right # 0~9を並び替えるならpermutationsかconbinations,N列のカテゴリを作るにはproduct from itertools import product, permutations, combinations, accumulate from functools import lru_cache # @lru_cache(maxsize=128) import operator from string import ascii_uppercase, ascii_lowercase, digits # 英字(大文字), 英字(小文字), 数字 MOD = 998244353 def II(): return int(input()) def LI(): return list(input()) def LMI(): return list(map(int, input().split())) def LMS(): return list(map(str, input().split())) def LLMI(x): return [list(map(int, input().split())) for _ in range(x)] def LLMS(x): return [list(input()) for _ in range(x)] def execute(): n, d = LMI() dp = [[-float('INF')] * 2 for _ in range(n+1)] dp[0][0] = 0 for i in range(n): t, k = LMI() for j in range(2): if j == 0: dp[i + 1][j] = max(dp[i][j] + t, dp[i][j^1] + t - d) else: dp[i + 1][j] = max(dp[i][j^1] + k - d, dp[i][j] + k) # print(dp) print(max(dp[-1])) if __name__ == "__main__": T = 1 for _ in range(T): execute()