結果

問題 No.126 2基のエレベータ
ユーザー cureskol
提出日時 2020-04-04 13:04:37
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 248 bytes
コンパイル時間 1,833 ms
コンパイル使用メモリ 165,552 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-03 07:14:27
合計ジャッジ時間 2,249 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
  }
  int ans=abs(s-b);
  if(a==0)ans++,a=1;
  cout<<ans+min(abs(a-s)+a,s-1+a-1+1)<<endl;
}
0