結果
| 問題 | 
                            No.859 路線A、路線B、路線C
                             | 
                    
| コンテスト | |
| ユーザー | 
                             ayaoni
                         | 
                    
| 提出日時 | 2020-12-20 08:51:28 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 928 bytes | 
| コンパイル時間 | 246 ms | 
| コンパイル使用メモリ | 82,248 KB | 
| 実行使用メモリ | 54,300 KB | 
| 最終ジャッジ日時 | 2024-09-21 11:34:25 | 
| 合計ジャッジ時間 | 1,443 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 5 WA * 7 | 
ソースコード
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)
            
            
            
        
            
ayaoni