結果

問題 No.859 路線A、路線B、路線C
ユーザー Nagisa
提出日時 2019-08-10 00:02:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 42 ms / 1,000 ms
コード長 825 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 52,224 KB
最終ジャッジ日時 2024-07-19 16:02:25
合計ジャッジ時間 1,347 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

x, y, z = map(int,input().split())
S0, t0 = input().split()
S1, t1 = input().split()
t0, t1 = int(t0), int(t1)

if S0 == S1 == "A":
    print(min(abs(t0-t1),x+y-abs(t0-t1)))
elif S0 == S1 == "B":
    print(min(abs(t0-t1),x+y-abs(t0-t1),y+z-abs(t0-t1)))
elif S0 == S1 == "C":
    print(min(abs(t0-t1),z+y-abs(t0-t1)))

elif S0 == "A" and S1 == "B":
    print(min(t0+t1-1,x+y-(t0+t1-1),t0+z+y-t1,x-t0+z+t1))

elif S0 == "B" and S1 == "A":
    print(min(t0+t1-1,x+y-(t0+t1-1),t1+z+y-t0,x-t1+z+t0))

elif S0 == "C" and S1 == "B":
    print(min(t0+t1-1,z+y-(t0+t1-1),t1+x+z-t0,y-t1+x+t0))
elif S0 == "B" and S1 == "C":
    print(min(t0+t1-1,z+y-(t0+t1-1),t0+x+z-t1,y-t0+x+t1))

elif S0 == "A" and S1 == "C":
    print(min(t0+t1-1,z+x-(t0+t1-1),t0+z-t1+y,x-t0+t1+y))
else:
    print(min(t0+t1-1,z+x-(t0+t1-1),t1+z-t0+y,x-t1+t0+y))
0