結果

問題 No.859 路線A、路線B、路線C
ユーザー kotatsugamekotatsugame
提出日時 2019-08-09 22:16:33
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 384 bytes
コンパイル時間 544 ms
コンパイル使用メモリ 66,868 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-26 18:15:19
合計ジャッジ時間 1,301 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 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 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:5:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    5 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
long x,y,z;
main()
{
	char s,t;
	long S,T;
	cin>>x>>y>>z>>s>>S>>t>>T;
	long ans,inf=1e9;
	long ss=s=='A'?x:s=='B'?y:z;
	long tt=t=='A'?x:s=='B'?y:z;
	if(s==t)ans=min(abs(T-S),min({s=='A'?inf:x,s=='B'?inf:y,s=='C'?inf:z})+ss-abs(T-S));
	else ans=min(S+min(T-1,x+y+z-ss-T),ss-S+min(tt-T+1,T+x+y+z-ss-tt));
	cout<<ans<<endl;
}
0