結果
問題 | No.126 2基のエレベータ |
ユーザー |
|
提出日時 | 2023-02-04 15:54:22 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 132 ms / 5,000 ms |
コード長 | 492 bytes |
コンパイル時間 | 2,345 ms |
コンパイル使用メモリ | 74,604 KB |
実行使用メモリ | 41,748 KB |
最終ジャッジ日時 | 2024-07-03 13:04:55 |
合計ジャッジ時間 | 6,799 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
import java.util.Scanner;class Main{public static void main(String[] args) {Scanner sc = new Scanner(System.in);int a = sc.nextInt(),b = sc.nextInt(),s = sc.nextInt(),count = 0;if(Math.abs(a - s) <= Math.abs(b - s) || s == 1) {count += Math.abs(a - s) + s;}else {count += Math.abs(b - s);if(Math.abs(s - a) + a > (s - 1) + a) {count += s - 1 + a;if(a == 0)count += 2;}else {count += Math.abs(s - a) + a;}}System.out.println(count);}}