結果
| 問題 |
No.126 2基のエレベータ
|
| コンテスト | |
| ユーザー |
tsunatama5
|
| 提出日時 | 2015-02-08 13:54:26 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 669 bytes |
| コンパイル時間 | 3,314 ms |
| コンパイル使用メモリ | 77,952 KB |
| 実行使用メモリ | 41,664 KB |
| 最終ジャッジ日時 | 2024-06-23 10:56:49 |
| 合計ジャッジ時間 | 8,000 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| 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-1) + Math.abs(a-1) + 1;
} else if ((Math.abs(s-a) > Math.abs(s-b) && a == 1)){
ans = Math.abs(s-b) + Math.abs(s-1) + 2;
}
System.out.println(ans);
}
}
tsunatama5