結果
| 問題 | No.126 2基のエレベータ |
| コンテスト | |
| ユーザー |
YamaKasa
|
| 提出日時 | 2018-07-14 15:53:37 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 582 bytes |
| 記録 | |
| コンパイル時間 | 2,079 ms |
| コンパイル使用メモリ | 73,968 KB |
| 実行使用メモリ | 54,352 KB |
| 最終ジャッジ日時 | 2024-10-10 05:11:45 |
| 合計ジャッジ時間 | 7,033 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 WA * 1 |
ソースコード
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int A = scan.nextInt();
int B = scan.nextInt();
int S = scan.nextInt();
scan.close();
int l1 = Math.abs(S - A);
int l2 = Math.abs(S - B);
if(l1 <= l2) {
int ans = l1 + S;
System.out.println(ans);
}else {
int ans = l2;
if(A == 0) {
ans += 2 + S - 1;
System.out.println(ans);
System.exit(0);
}
int t1 = l1 + A;
int t2 = S + Math.abs(A - 1);
ans += Math.min(t1, t2);
System.out.println(ans);
}
}
}
YamaKasa