結果
| 問題 |
No.859 路線A、路線B、路線C
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-08-09 22:16:33 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 384 bytes |
| コンパイル時間 | 568 ms |
| コンパイル使用メモリ | 67,852 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-19 12:13:23 |
| 合計ジャッジ時間 | 1,207 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
5 | main()
| ^~~~
ソースコード
#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;
}