結果

問題 No.561 東京と京都
ユーザー fal_rndfal_rnd
提出日時 2017-08-25 22:48:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 679 bytes
コンパイル時間 2,262 ms
コンパイル使用メモリ 81,996 KB
実行使用メモリ 41,780 KB
最終ジャッジ日時 2024-04-23 16:05:42
合計ジャッジ時間 5,216 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
41,080 KB
testcase_01 AC 103 ms
41,024 KB
testcase_02 AC 104 ms
41,472 KB
testcase_03 AC 108 ms
39,928 KB
testcase_04 AC 99 ms
39,928 KB
testcase_05 AC 108 ms
39,860 KB
testcase_06 AC 101 ms
41,508 KB
testcase_07 AC 108 ms
40,252 KB
testcase_08 AC 114 ms
41,404 KB
testcase_09 AC 100 ms
41,076 KB
testcase_10 AC 105 ms
41,164 KB
testcase_11 AC 124 ms
41,244 KB
testcase_12 AC 124 ms
41,388 KB
testcase_13 AC 119 ms
41,576 KB
testcase_14 AC 121 ms
41,780 KB
testcase_15 AC 119 ms
41,256 KB
testcase_16 AC 118 ms
41,356 KB
testcase_17 AC 124 ms
41,384 KB
testcase_18 AC 130 ms
41,608 KB
testcase_19 AC 127 ms
41,384 KB
testcase_20 AC 119 ms
41,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n) {return REPS(n).map(i->getInt());}
	static Scanner s=new Scanner(System.in);
	static int getInt(){return Integer.parseInt(s.next());}

	public static void main(String[]$){
		int n=getInt(),c=getInt(),r[]={0,-1145141919};
		for(int i=0;i<n;++i) {
			int tokyo=getInt(),kyoto=getInt();
			int r1=tokyo+Math.max(r[0],r[1]-c);
			int r2=kyoto+Math.max(r[0]-c,r[1]);
			r[0]=r1;
			r[1]=r2;
		}
		System.out.println(Math.max(r[0],r[1]));
	}
}
0