結果
問題 |
No.126 2基のエレベータ
|
ユーザー |
![]() |
提出日時 | 2015-02-08 13:39:54 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 608 bytes |
コンパイル時間 | 3,218 ms |
コンパイル使用メモリ | 74,940 KB |
実行使用メモリ | 54,304 KB |
最終ジャッジ日時 | 2024-06-23 10:55:38 |
合計ジャッジ時間 | 8,031 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 WA * 7 |
ソースコード
package P126; import java.util.Scanner; public class P126 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String r = sc.nextLine(); String[] rstrs = r.split(" ",0); int a = Integer.parseInt(rstrs[0]); int b = Integer.parseInt(rstrs[1]); int s = Integer.parseInt(rstrs[2]); int ans = 0; if (Math.abs(s-a) <= Math.abs(s-b)) { ans = Math.abs(s-a) + (s-0); } else if (Math.abs(s-a) > Math.abs(s-b) && a >= 1) { ans = Math.abs(s-b) + Math.abs(s-a) + a; } else { ans = Math.abs(s-b) + Math.abs(s-1) + 2; } System.out.println(ans); } }