結果

問題 No.859 路線A、路線B、路線C
ユーザー kotatsugamekotatsugame
提出日時 2019-08-09 22:12:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 384 bytes
コンパイル時間 502 ms
コンパイル使用メモリ 67,680 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-19 12:09:56
合計ジャッジ時間 1,102 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 WA * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-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,T-1+x+y+z-ss-tt));
	cout<<ans<<endl;
}
0