結果
問題 |
No.561 東京と京都
|
ユーザー |
|
提出日時 | 2017-09-19 23:11:00 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 853 bytes |
コンパイル時間 | 3,533 ms |
コンパイル使用メモリ | 74,564 KB |
実行使用メモリ | 42,180 KB |
最終ジャッジ日時 | 2024-11-08 05:49:11 |
合計ジャッジ時間 | 7,608 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 9 WA * 8 |
ソースコード
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, more, result = 0, resultK = -d; boolean tokyo = true; for(int i = 0; i < n; i++) { t = sc.nextInt(); k = sc.nextInt(); if( tokyo ) { more = max(t, k - d); if(t != k - d && more == k - d) tokyo = false; result += more; } else { more = max(t - d, k); if(t - d != k && more == t - d) tokyo = true; result += more; } resultK += k; } System.out.println(result < resultK ? resultK : result); } }