結果

問題 No.859 路線A、路線B、路線C
ユーザー akitsugu777akitsugu777
提出日時 2019-09-02 13:19:14
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 28 ms / 1,000 ms
コード長 666 bytes
コンパイル時間 202 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-12-15 04:22:31
合計ジャッジ時間 1,107 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

a, b, c = map(int,input().split())
S = input().split()
s = int(S[1])
G = input().split()
g = int(G[1])

if S[0] == G[0]:
    if s > g:
        s, g = g, s
    if S[0] == 'B':
        a, b, c = b, a, c
    elif S[0] == 'C':
        a, b, c = c, b, a
    x = min(g-s, s+c+a-g, s+b+a-g)

else:
    if S[0] == 'A' and G[0] == 'B':
        a, b, c = a, c, b
    elif S[0] == 'B' and G[0] == 'A':
        a, b, c = b, c, a
    elif S[0] == 'B' and G[0] == 'C':
        a, b, c = b, a, c
    elif S[0] == 'C' and G[0] == 'A':
        a, b, c = c, b, a
    elif S[0] == 'C' and G[0] == 'B':
        a, b, c = c, a, b
    x = min(s+g-1, a-s+c-g+1, a-s+b+g, s+b+c-g)

print(x)
0