結果

問題 No.126 2基のエレベータ
ユーザー itezpace
提出日時 2016-07-29 07:05:49
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 442 bytes
コンパイル時間 713 ms
コンパイル使用メモリ 57,360 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-06 18:19:56
合計ジャッジ時間 1,741 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int a,b,s;
  cin>>a>>b>>s;
  if(s==1){
    if(a>0){
      cout<<a<<endl;
    } else if(a==0){
      cout<<2<<endl;
    }
    return 0;
  }
  int x,y,z;
  x=abs(a-s);
  y=abs(b-s);
  if(x<=y){
    if(x>=s){
      z=a;
    } else {
      z=x+s;
    }
  } else {
    if(y>=s){
      z=b-1;
    } else {
      z=y+s-1;
    }
    z+=a;
  }
  cout<<z<<endl;
  return 0;
}
0