結果
| 問題 |
No.126 2基のエレベータ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-01-13 23:29:31 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 710 bytes |
| コンパイル時間 | 1,688 ms |
| コンパイル使用メモリ | 157,672 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-21 19:11:00 |
| 合計ジャッジ時間 | 2,201 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 WA * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define ITER(c) __typeof__((c).begin())
#define FOREACH(it, c) for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define REP(i, n) for(int(i)=0;(i)<(n);++(i))
#define RREP(i, n) for(int(i)=(n)-1;(i)>=0;--(i))
const int MOD = (int)1e9+7;
int N,M,W,H;
int main(){
int A,B,S;
cin >> A >> B >> S;
if(abs(A-S) <= abs(B-S)){
cout << abs(A-S) + S << endl;
} else {
int minv = abs(B-S) + S - 1 + abs(A-1) + 1;
if(A != 0){
minv = min(minv, abs(B-S) + abs(A-S) + A);
}
cout << minv << endl;
}
}