結果
問題 | No.859 路線A、路線B、路線C |
ユーザー |
![]() |
提出日時 | 2019-08-19 13:29:59 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 782 bytes |
コンパイル時間 | 630 ms |
コンパイル使用メモリ | 72,344 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-04 04:54:30 |
合計ジャッジ時間 | 1,278 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
#include <algorithm> #include <iostream> #include <vector> using namespace std; template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } int main() { vector<long long> c(3); for (long long &ci: c) cin >> ci; char s0, s1; long long t0, t1; cin >> s0 >> t0 >> s1 >> t1; s0 -= 'A', s1 -= 'A'; if (s0 == s1) { swap(c[0], c[s0]); if (t0 > t1) swap(t0, t1); long long ans = min(t1 - t0, t0 + min(c[1], c[2]) + c[0] - t1); cout << ans << endl; } else { long long x = c[s0], y = c[s1], z = c[3 - s0 - s1]; long long ans = min({ t0 + t1 - 1, x - t0 + y - t1 + 1, t0 + z + y - t1, x - t0 + z + t1 }); cout << ans << endl; } return 0; }