結果

問題 No.561 東京と京都
ユーザー ch1channnch1channn
提出日時 2023-04-08 14:15:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 792 bytes
コンパイル時間 382 ms
コンパイル使用メモリ 82,256 KB
実行使用メモリ 54,092 KB
最終ジャッジ日時 2024-04-14 11:47:45
合計ジャッジ時間 2,166 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,228 KB
testcase_01 AC 36 ms
53,620 KB
testcase_02 AC 36 ms
52,456 KB
testcase_03 AC 36 ms
53,016 KB
testcase_04 AC 37 ms
52,616 KB
testcase_05 AC 36 ms
52,740 KB
testcase_06 AC 35 ms
52,988 KB
testcase_07 AC 36 ms
53,400 KB
testcase_08 AC 36 ms
52,832 KB
testcase_09 AC 37 ms
52,788 KB
testcase_10 AC 36 ms
52,684 KB
testcase_11 AC 36 ms
52,764 KB
testcase_12 AC 38 ms
53,360 KB
testcase_13 AC 37 ms
53,096 KB
testcase_14 AC 37 ms
53,812 KB
testcase_15 AC 37 ms
52,824 KB
testcase_16 AC 38 ms
54,092 KB
testcase_17 AC 38 ms
53,480 KB
testcase_18 AC 38 ms
52,864 KB
testcase_19 AC 37 ms
52,756 KB
testcase_20 AC 38 ms
52,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
if sys.platform =='ios':
	import clipboard
	a=clipboard.get()
	a = a.split('\n')
	text = '\n'.join(a)
	with open('input_file.txt','w') as f:
		f.write(text)
	sys.stdin = open('input_file.txt')
sys.setrecursionlimit(410000000)
stdin = sys.stdin 
ni = lambda: int(ns())
ni_1 = lambda: int(ns())-1
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()
nm = lambda: map(int,input().split())
na_1 = lambda: list(map(lambda x:int(x)*(-1), stdin.readline().split()))
na_2 = lambda: list(map(lambda x:int(x)-1, stdin.readline().split()))
N,D = nm()
dp = [[0,0] for i in range(N+1)]
dp[0][1] = -10**10
for i in range(1,N+1):
	t,k = nm()
	dp[i][0] = max(dp[i-1][0]+t,dp[i-1][1]-D+t)
	dp[i][1] = max(dp[i-1][1]+k,dp[i-1][0]-D+k)
		
		
print(max(dp[-1]))
0