結果

問題 No.859 路線A、路線B、路線C
ユーザー kamojiro24ekamojiro24e
提出日時 2019-08-09 22:35:13
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
実行時間 -
コード長 899 bytes
コンパイル時間 369 ms
コンパイル使用メモリ 10,964 KB
実行使用メモリ 7,992 KB
最終ジャッジ日時 2023-09-26 20:50:59
合計ジャッジ時間 1,445 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,776 KB
testcase_01 AC 15 ms
7,824 KB
testcase_02 AC 14 ms
7,812 KB
testcase_03 AC 15 ms
7,868 KB
testcase_04 WA -
testcase_05 AC 15 ms
7,808 KB
testcase_06 AC 15 ms
7,824 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 16 ms
7,876 KB
testcase_10 WA -
testcase_11 AC 15 ms
7,824 KB
testcase_12 AC 15 ms
7,784 KB
testcase_13 AC 15 ms
7,924 KB
testcase_14 AC 15 ms
7,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#import sys
#input = sys.stdin.readline
def main():
    x, y, z = map( int, input().split())
    s0, t0 = input().split()
    s1, t1 = input().split()
    t0, t1 = int(t0), int(t1)
    if t0 > t1:
        s0, s1 = s1, s0
        t0, t1 = t1, t0
    if s0 != "A":
        if s0 == s1:
            if s0 == "B":
                x, y = y, x
            else:
                x, z = z, x
            s0 = s1 = "A"
        else:
            if s1 == "B":
                x, z = z, x
            else:
                x, y = y, x
            s0 = "A"
    if s1 == "C":
        y, z = z, y
        s1 = "B"
#    print(x,y,z,s0,t0,s1,t1)
    if s0 == s1:
        print( min(t1 - t0, t0 + x+1-t1 + min(y-1, z-1)))
    else:
#            print(  min(t0, x-t0 + z) + t1-1, min(x+1-t0, t0+z) +y-t1)
        print( min( min(t0, x+1-t0 + z) + t1-1, min(x+1-t0, t0+z) +y-t1))
if __name__ == '__main__':
    main()
0