結果
| 問題 | 
                            No.126 2基のエレベータ
                             | 
                    
| コンテスト | |
| ユーザー | 
                             takeya_okino
                         | 
                    
| 提出日時 | 2019-09-12 23:22:34 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 468 bytes | 
| コンパイル時間 | 2,217 ms | 
| コンパイル使用メモリ | 74,196 KB | 
| 実行使用メモリ | 56,204 KB | 
| 最終ジャッジ日時 | 2024-07-02 17:15:46 | 
| 合計ジャッジ時間 | 6,982 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 21 WA * 6 | 
ソースコード
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 ans = 0;
    if(Math.abs(a - s) <= Math.abs(b - s)) {
      ans = Math.abs(a - s) + s;
    } else {
      ans = Math.abs(b - s) + Math.abs(a - s) + a;
      if(a == 0) ans++;
    }
    if(s == 1) ans = Math.abs(a - s) + 1;
    System.out.println(ans);
  }
}
            
            
            
        
            
takeya_okino