結果
問題 |
No.126 2基のエレベータ
|
ユーザー |
|
提出日時 | 2017-02-23 14:35:39 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 853 bytes |
コンパイル時間 | 1,460 ms |
コンパイル使用メモリ | 165,876 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-10 18:31:42 |
合計ジャッジ時間 | 2,439 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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_back typedef long long ll; typedef vector<int> vi; typedef vector<double> vd; typedef vector<long long> vll; typedef vector<string> vs; typedef vector<bool> vb; inline int f() { int a, b, s; cin >> a >> b >> s; int da = abs(s - a), db = abs(s - b); if(s == 1) return da + 1; if (da <= db) return da + s; int ans = db + s + abs(1 - a); return (a != 0) ? min(ans, db + da + a) : ans; } int main() { P(f()); return 0; }