結果
問題 | No.126 2基のエレベータ |
ユーザー | mayoko_ |
提出日時 | 2015-01-13 23:36:22 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 873 bytes |
コンパイル時間 | 547 ms |
コンパイル使用メモリ | 72,944 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-21 19:11:08 |
合計ジャッジ時間 | 1,611 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 WA * 2 |
ソースコード
#include <sstream> #include <string> #include <vector> #include <map> #include <algorithm> #include <iostream> #include <utility> #include <set> #include <cctype> #include <queue> #include <stack> #include <cstdio> #include <cstdlib> #include <cmath> #define INF 1000000000 using namespace std; typedef long long ll; int main(void) { int A, B, S; cin >> A >> B >> S; int ans = 0; if (S == 0) { cout << 0 << endl; } if (S == 1) { ans += abs(S-A); ans += S; cout << ans << endl; return 0; } if (abs(S-B) < abs(S-A)) { ans += abs(S-B); ans += abs(S-1); ans += abs(A-1); ans += 1; int can = abs(S-B) + abs(A-S) + A; cout << min(ans, can) << endl; } else { ans += abs(S-A); ans += S; cout << ans << endl; } return 0; }