結果

問題 No.808 Kaiten Sushi?
ユーザー titiatitia
提出日時 2019-03-22 23:14:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,537 bytes
コンパイル時間 500 ms
コンパイル使用メモリ 81,576 KB
実行使用メモリ 116,944 KB
最終ジャッジ日時 2023-10-19 10:28:56
合計ジャッジ時間 8,539 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,376 KB
testcase_01 AC 39 ms
53,376 KB
testcase_02 AC 39 ms
53,376 KB
testcase_03 AC 39 ms
53,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 39 ms
53,376 KB
testcase_07 AC 70 ms
64,240 KB
testcase_08 AC 53 ms
64,248 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 64 ms
68,968 KB
testcase_13 AC 63 ms
68,976 KB
testcase_14 AC 51 ms
62,128 KB
testcase_15 AC 68 ms
71,048 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 44 ms
55,432 KB
testcase_21 AC 41 ms
53,384 KB
testcase_22 AC 43 ms
55,432 KB
testcase_23 AC 103 ms
89,168 KB
testcase_24 AC 95 ms
87,240 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 239 ms
116,944 KB
testcase_33 AC 154 ms
95,912 KB
testcase_34 AC 169 ms
95,836 KB
testcase_35 AC 192 ms
103,896 KB
testcase_36 AC 155 ms
95,864 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 186 ms
107,028 KB
testcase_40 AC 92 ms
82,788 KB
testcase_41 AC 117 ms
83,960 KB
testcase_42 AC 173 ms
96,324 KB
testcase_43 AC 132 ms
89,188 KB
testcase_44 AC 147 ms
93,360 KB
testcase_45 AC 135 ms
89,260 KB
testcase_46 AC 122 ms
81,736 KB
testcase_47 AC 197 ms
112,044 KB
testcase_48 AC 199 ms
112,048 KB
testcase_49 AC 199 ms
112,044 KB
testcase_50 AC 198 ms
112,048 KB
testcase_51 AC 197 ms
112,044 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 40 ms
53,384 KB
testcase_55 AC 40 ms
53,384 KB
testcase_56 AC 40 ms
53,384 KB
testcase_57 AC 94 ms
88,856 KB
testcase_58 AC 105 ms
91,792 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=-1
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