結果
問題 |
No.126 2基のエレベータ
|
ユーザー |
![]() |
提出日時 | 2015-01-25 15:38:02 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 477 bytes |
コンパイル時間 | 2,221 ms |
コンパイル使用メモリ | 73,612 KB |
実行使用メモリ | 41,628 KB |
最終ジャッジ日時 | 2024-06-23 02:35:44 |
合計ジャッジ時間 | 6,900 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 WA * 10 |
ソースコード
import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int s = sc.nextInt(); int sum = 0; if(Math.abs(a-s) < Math.abs(b-s)){ // aの方が近い sum += Math.abs(a-s) + s; }else{ // bの方が近い sum += Math.abs(b-s) + Math.abs(s-a) + a; if(a == 0 && (Math.abs(a-s) != Math.abs(b-s))) { sum++; } } System.out.println(sum); } }