結果
| 問題 |
No.561 東京と京都
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-09-20 21:01:29 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 754 bytes |
| コンパイル時間 | 4,429 ms |
| コンパイル使用メモリ | 74,216 KB |
| 実行使用メモリ | 41,824 KB |
| 最終ジャッジ日時 | 2024-11-08 09:15:21 |
| 合計ジャッジ時間 | 8,165 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 14 WA * 3 |
ソースコード
package yukicoder;
import java.util.Scanner;
import static java.lang.Math.max;
public class No561 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), d = sc.nextInt();
int t, k, beforeT, beforeK;
int resultT = 0, resultK = 0;
boolean tokyo = true;
beforeT = sc.nextInt();
beforeK = sc.nextInt() - d;
for(int i = 0; i < n - 1; i++) {
t = sc.nextInt();
k = sc.nextInt();
resultT = t + max(beforeT, beforeK - d);
resultK = k + max(beforeK, beforeT - d);
beforeT = resultT;
beforeK = resultK;
}
System.out.println(max(resultT, resultK));
}
}