結果
| 問題 |
No.126 2基のエレベータ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-09-20 09:32:35 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 555 bytes |
| コンパイル時間 | 405 ms |
| コンパイル使用メモリ | 56,688 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-10 18:30:42 |
| 合計ジャッジ時間 | 1,235 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int A,B,S;
cin>>A>>B>>S;
int da=abs(S-A);
int db=abs(S-B);
int az=0;
if(A==0) az=1;
int ap=0;
if(A<S) ap=1;
int sp=0;
if(S==1) sp=1;
int ans=0;
if(sp==0){
if(da<=db){
ans=da+S;
} else if(da>db && ap==0){
int ans1=db+da+da+S;
int ans2=db+S-1+A;
ans=min(ans1,ans2);
} else if(da>db && ap==1 && az==0){
ans=db+S;
} else if(da>db && ap==1 && az==1){
ans=db+S-1+2;
}
} else {
ans=da+S;
}
cout<<ans<<endl;
return 0;
}