結果
問題 | No.859 路線A、路線B、路線C |
ユーザー |
|
提出日時 | 2019-08-10 05:46:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 29 ms / 1,000 ms |
コード長 | 687 bytes |
コンパイル時間 | 2,087 ms |
コンパイル使用メモリ | 194,788 KB |
最終ジャッジ日時 | 2025-01-07 11:37:51 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); long long x, y, z; cin >> x >> y >> z; char s[2]; long long a[2], b[2]; for (int i = 0; i < 2; i++) { cin >> s[i] >> a[i]; if (s[i] == 'A') b[i] = x - a[i]; if (s[i] == 'B') b[i] = y - a[i]; if (s[i] == 'C') b[i] = z - a[i]; a[i]--; } long long ans = 1LL << 60; if (s[0] == s[1]) ans = abs(a[0] - a[1]); ans = min(ans, a[0] + a[1] + 1); ans = min(ans, b[0] + b[1] + 1); ans = min(ans, a[0] + b[1] + 1 + min({x, y, z})); ans = min(ans, a[1] + b[0] + 1 + min({x, y, z})); cout << ans << endl; return 0; }