結果

問題 No.859 路線A、路線B、路線C
ユーザー ayaoniayaoni
提出日時 2020-12-20 08:51:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 928 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 81,688 KB
実行使用メモリ 53,480 KB
最終ジャッジ日時 2023-10-21 10:28:11
合計ジャッジ時間 1,993 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


x,y,z = MI()
s,t0 = S().split()
t0 = int(t0)
g,t1 = S().split()
t1 = int(t1)

if s == g:
    if t0 > t1:
        t0,t1 = t1,t0
    if s == 'B':
        y,x = x,y
    if s == 'C':
        x,y = y,x
    ans = min(t1-t0,t0+min(y,z)+(x-t1))
    print(ans)
else:
    if s == 'B':
        x,y = y,x
    if s == 'C':
        x,z = z,x
    if g == 'A':
        x,y = y,x
    if g == 'C':
        y,z = z,y
    ans = min(t0+t1-1,(x-t0)+(y-t1),t0+z+(y-t1),(x-t0)+z+t1-1)
    print(ans)
0