結果
問題 |
No.561 東京と京都
|
ユーザー |
|
提出日時 | 2017-09-19 23:19:36 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 893 bytes |
コンパイル時間 | 5,121 ms |
コンパイル使用メモリ | 75,016 KB |
実行使用メモリ | 41,844 KB |
最終ジャッジ日時 | 2024-11-08 05:49:24 |
合計ジャッジ時間 | 7,097 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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, resultT = -d, 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; } resultT += t; resultK += k; } System.out.println(max(max(resultT, resultK), result)); } }