結果
問題 |
No.126 2基のエレベータ
|
ユーザー |
![]() |
提出日時 | 2018-07-14 15:56:12 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 646 bytes |
コンパイル時間 | 2,388 ms |
コンパイル使用メモリ | 74,460 KB |
実行使用メモリ | 41,640 KB |
最終ジャッジ日時 | 2024-10-10 05:16:20 |
合計ジャッジ時間 | 7,747 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 27 |
ソースコード
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(S == 1) { System.out.println(A); System.exit(0); } 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); } } }