結果
問題 | No.126 2基のエレベータ |
ユーザー |
|
提出日時 | 2017-02-23 14:18:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 890 bytes |
コンパイル時間 | 1,618 ms |
コンパイル使用メモリ | 167,240 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-10 18:31:25 |
合計ジャッジ時間 | 2,430 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#include <bits/stdc++.h>using namespace std;struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;#define P(x) cout << (x) << endl#define p(x) cout << (x)#define all(c) (c).begin(), (c).end()#define rall(c) (c).rbegin(), (c).rend()#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)#define rrep(i,a,n) for(int i=(a); i>n; --i)#define len(x) ((int)(x).size())#define mp make_pair#define eb emplace_backtypedef long long ll;typedef vector<int> vi;typedef vector<double> vd;typedef vector<long long> vll;typedef vector<string> vs;typedef vector<bool> vb;int main() {cout << setprecision(13) << fixed;int a, b, s; cin >> a >> b >> s;int da = abs(s - a);int db = abs(s - b);int ans;if(s == 1) ans = da + 1;else if (da <= db) ans = da + s;else {ans = db + s + abs(1 - a);if(a != 0) ans = min(ans, db + da + a);}P(ans);return 0;}