結果
| 問題 | No.126 2基のエレベータ |
| コンテスト | |
| ユーザー |
alpha_virginis
|
| 提出日時 | 2015-03-05 22:26:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 615 bytes |
| コンパイル時間 | 586 ms |
| コンパイル使用メモリ | 66,156 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-10 18:24:37 |
| 合計ジャッジ時間 | 1,448 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
int main() {
long i;
long a, b, s;
long a_s;
long b_s;
long ans;
long route1, route2;
std::cin >> a >> b >> s;
a_s = abs(a-s);
b_s = abs(b-s);
if( s == 1 || a_s <= b_s ) {
ans = a_s + s;
}
else {
if( a == 0 ) {
ans = b_s + abs(s-1) + 2;
}
else {
route1 = b_s + abs(s-a) + a;
route2 = b_s + abs(s-1) + a;
if(route2 < route1) {
ans = route2;
}
else {
ans = route1;
}
}
}
std::cout << ans << std::endl;
return 0;
}
alpha_virginis