結果
| 問題 | 
                            No.126 2基のエレベータ
                             | 
                    
| コンテスト | |
| ユーザー | 
                             cureskol
                         | 
                    
| 提出日時 | 2020-04-04 13:05:59 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 306 bytes | 
| コンパイル時間 | 1,486 ms | 
| コンパイル使用メモリ | 165,632 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-10 18:36:35 | 
| 合計ジャッジ時間 | 2,305 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 27 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
signed main(){
  int a,b,s;cin>>a>>b>>s;
  if(abs(s-a)<=abs(s-b)){
    cout<<abs(s-a)+s<<endl;
    return 0;
  }
  if(s==1){
    cout<<abs(a-1)+1<<endl;
    return 0;
  }
  int ans=abs(s-b);
  if(a==0)ans++,a=1;
  cout<<ans+min(abs(a-s)+a,s-1+a-1+1)<<endl;
}
            
            
            
        
            
cureskol