結果

問題 No.859 路線A、路線B、路線C
ユーザー rin204
提出日時 2022-07-10 16:35:27
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 628 bytes
コンパイル時間 675 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 52,224 KB
最終ジャッジ日時 2025-01-03 12:41:48
合計ジャッジ時間 2,215 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

x, y, z = map(int, input().split())
ss = input().split()
tt = input().split()
ss[1] = int(ss[1])
tt[1] = int(tt[1])

if ss[0] == tt[0]:
    ans = abs(ss[1] - tt[1])
else:
    ans = ss[1] + tt[1] - 1
    for a in (ss, tt):
        if a[0] == "A":
            a.append(x - a[1])
        elif a[0] == "B":
            a.append(y - a[1])
        else:
            a.append(z - a[1])
    ans = min(ans, ss[2] + tt[2] + 1)
    tmp = min(ss[1] + tt[2], ss[2] + tt[1])
    if "A" not in [ss[0], tt[0]]:
        tmp += x
    elif "B" not in [ss[0], tt[0]]:
        tmp += y
    else:
        tmp += z
    ans = min(ans, tmp)
print(ans)

0