結果
| 問題 |
No.126 2基のエレベータ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-01-22 20:28:30 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 765 bytes |
| コンパイル時間 | 773 ms |
| コンパイル使用メモリ | 90,044 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-23 00:21:58 |
| 合計ジャッジ時間 | 1,918 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 WA * 12 |
ソースコード
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;
int main()
{
int a, b, s;
cin >> a >> b >> s;
int ret;
if(abs(a - s) <= abs(b - s)){
ret = abs(a - s) + s;
}
else if(s == 1){
ret = abs(a - 1) + 1;
}
else{
ret = abs(b - s) + (b - 1) + abs(a - 1) + 1;
if(a > 0)
ret = min(ret, abs(b - s) + abs(s - a) + a);
}
cout << ret << endl;
return 0;
}