結果

問題 No.859 路線A、路線B、路線C
ユーザー yuruhiyayuruhiya
提出日時 2019-08-09 22:44:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 580 bytes
コンパイル時間 556 ms
コンパイル使用メモリ 73,160 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-26 21:00:14
合計ジャッジ時間 1,304 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	vector<int> x(3);
	cin >> x[0] >> x[1] >> x[2];
	char S0, S1; int t0, t1;
	cin >> S0 >> t0 >> S1 >> t1;

	auto Inter = [=](bool i, char S, long long t) {
		return i ? t : x[S - 'A'] - t + 1;
	};

	int Xmin = min({ x[0],x[1],x[2] }) - 1;
	cout << min({
		S0 == S1 ? abs(t0 - t1) : (long long)2e9,
		Inter(1, S0, t0) + Inter(1, S1, t1) - 1, Inter(0, S0, t0) + Inter(0, S1, t1) - 1,
		Inter(1, S0, t0) + Xmin + Inter(0, S1, t1), Inter(0, S0, t0) + Xmin + Inter(2, S1, t1),
		}) << endl;
}
0