結果

問題 No.808 Kaiten Sushi?
ユーザー titiatitia
提出日時 2019-03-22 23:30:45
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,536 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 81,624 KB
実行使用メモリ 116,936 KB
最終ジャッジ日時 2023-10-19 10:51:02
合計ジャッジ時間 8,231 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,420 KB
testcase_01 AC 39 ms
53,420 KB
testcase_02 AC 40 ms
53,420 KB
testcase_03 AC 39 ms
53,420 KB
testcase_04 WA -
testcase_05 AC 39 ms
53,420 KB
testcase_06 AC 39 ms
53,420 KB
testcase_07 AC 51 ms
64,244 KB
testcase_08 AC 52 ms
64,244 KB
testcase_09 AC 69 ms
71,036 KB
testcase_10 AC 63 ms
68,432 KB
testcase_11 AC 60 ms
66,420 KB
testcase_12 AC 63 ms
68,964 KB
testcase_13 AC 64 ms
68,972 KB
testcase_14 AC 51 ms
62,124 KB
testcase_15 AC 68 ms
71,044 KB
testcase_16 AC 65 ms
68,976 KB
testcase_17 AC 54 ms
64,384 KB
testcase_18 AC 43 ms
55,468 KB
testcase_19 AC 40 ms
53,420 KB
testcase_20 AC 43 ms
55,468 KB
testcase_21 AC 41 ms
53,420 KB
testcase_22 AC 42 ms
55,468 KB
testcase_23 AC 102 ms
89,164 KB
testcase_24 AC 95 ms
87,236 KB
testcase_25 AC 105 ms
89,632 KB
testcase_26 AC 103 ms
89,104 KB
testcase_27 AC 214 ms
113,192 KB
testcase_28 AC 113 ms
85,148 KB
testcase_29 AC 202 ms
107,708 KB
testcase_30 AC 155 ms
96,456 KB
testcase_31 AC 221 ms
115,392 KB
testcase_32 AC 235 ms
116,936 KB
testcase_33 AC 151 ms
95,904 KB
testcase_34 AC 166 ms
95,824 KB
testcase_35 AC 190 ms
103,888 KB
testcase_36 AC 151 ms
95,856 KB
testcase_37 AC 38 ms
53,420 KB
testcase_38 AC 38 ms
53,420 KB
testcase_39 AC 185 ms
107,020 KB
testcase_40 AC 90 ms
82,776 KB
testcase_41 AC 115 ms
83,956 KB
testcase_42 AC 168 ms
96,332 KB
testcase_43 AC 129 ms
89,180 KB
testcase_44 AC 145 ms
93,368 KB
testcase_45 AC 131 ms
89,252 KB
testcase_46 AC 107 ms
81,732 KB
testcase_47 AC 201 ms
112,036 KB
testcase_48 AC 196 ms
112,040 KB
testcase_49 AC 195 ms
112,036 KB
testcase_50 AC 193 ms
112,040 KB
testcase_51 AC 191 ms
112,036 KB
testcase_52 AC 126 ms
94,208 KB
testcase_53 AC 160 ms
110,560 KB
testcase_54 AC 39 ms
53,420 KB
testcase_55 AC 39 ms
53,420 KB
testcase_56 AC 39 ms
53,420 KB
testcase_57 AC 94 ms
88,844 KB
testcase_58 AC 104 ms
91,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,L=map(int,input().split())
X=list(map(int,input().split()))
Y=list(map(int,input().split()))

X2=[[x,1] for x in X]
Y2=[[y,2] for y in Y]

ALL=X2+Y2
ALL.sort()

ALL_C=[ALL[0]+[1]]

for i in range(1,2*N):
    if ALL[i][1]==ALL[i-1][1]:
        ALL_C[-1][2]+=1
    else:
        ALL_C.append(ALL[i]+[1])


NOW=0
NOWkind=2
EAT=0
ANS=0
LEN=len(ALL_C)
i=0

while EAT<2*N:
    #print(ALL_C,NOW,NOWkind,ANS)
    if i==LEN:
        i=0

        for j in range(LEN):
            if ALL_C[j][2]==0:
                continue
            else:
                ALL_C2=[ALL_C[j]]
                break

        for k in range(j+1,LEN):
            if ALL_C[k][2]==0:
                continue
            if ALL_C[k][1]==ALL_C2[-1][1]:
                ALL_C2[-1][2]+=ALL_C[k][2]
            else:
                ALL_C2.append(ALL_C[k])

        if NOWkind==ALL_C2[0][1]==ALL_C2[-1][1]:
            ALL_C2[-1][2]+=ALL_C2[0][2]
            ALL_C2=ALL_C2[1:]

        ALL_C=ALL_C2
        LEN=len(ALL_C)
            

        
    dist,kind,num=ALL_C[i]
    if num==0 or kind==NOWkind:
        i+=1
    else:
        if NOW<dist:
            ANS+=dist-NOW
            ALL_C[i][2]-=1
            EAT+=1
            NOW=dist
            NOWkind=kind
        else:
            ANS+=dist+(L-NOW)
            ALL_C[i][2]-=1
            EAT+=1
            NOW=dist
            NOWkind=kind
        i+=1

print(ANS)
            
    
    
0