結果

問題 No.2423 Merge Stones
ユーザー titiatitia
提出日時 2023-08-23 07:10:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 973 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 86,720 KB
実行使用メモリ 86,032 KB
最終ジャッジ日時 2023-08-23 07:11:54
合計ジャッジ時間 61,339 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,232 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 68 ms
71,284 KB
testcase_05 AC 73 ms
75,632 KB
testcase_06 AC 74 ms
75,768 KB
testcase_07 WA -
testcase_08 AC 71 ms
71,196 KB
testcase_09 AC 70 ms
71,204 KB
testcase_10 AC 74 ms
75,864 KB
testcase_11 AC 1,378 ms
85,460 KB
testcase_12 AC 672 ms
84,692 KB
testcase_13 AC 688 ms
84,520 KB
testcase_14 AC 687 ms
84,752 KB
testcase_15 AC 680 ms
84,608 KB
testcase_16 AC 681 ms
84,596 KB
testcase_17 AC 676 ms
84,568 KB
testcase_18 AC 682 ms
84,564 KB
testcase_19 AC 675 ms
84,628 KB
testcase_20 AC 661 ms
84,824 KB
testcase_21 AC 693 ms
84,628 KB
testcase_22 AC 676 ms
84,808 KB
testcase_23 AC 674 ms
84,604 KB
testcase_24 AC 708 ms
84,568 KB
testcase_25 AC 676 ms
84,904 KB
testcase_26 AC 675 ms
84,664 KB
testcase_27 AC 688 ms
84,528 KB
testcase_28 AC 682 ms
84,616 KB
testcase_29 WA -
testcase_30 AC 706 ms
84,600 KB
testcase_31 AC 668 ms
84,572 KB
testcase_32 AC 703 ms
84,680 KB
testcase_33 AC 670 ms
84,612 KB
testcase_34 AC 673 ms
84,608 KB
testcase_35 AC 711 ms
84,572 KB
testcase_36 AC 671 ms
84,860 KB
testcase_37 AC 695 ms
84,568 KB
testcase_38 AC 681 ms
84,608 KB
testcase_39 WA -
testcase_40 AC 671 ms
84,608 KB
testcase_41 AC 671 ms
84,664 KB
testcase_42 AC 698 ms
84,632 KB
testcase_43 AC 677 ms
84,824 KB
testcase_44 WA -
testcase_45 AC 670 ms
84,900 KB
testcase_46 AC 698 ms
84,600 KB
testcase_47 AC 668 ms
84,812 KB
testcase_48 AC 681 ms
84,500 KB
testcase_49 AC 687 ms
84,572 KB
testcase_50 AC 664 ms
84,608 KB
testcase_51 AC 1,379 ms
84,996 KB
testcase_52 AC 1,325 ms
85,108 KB
testcase_53 AC 1,345 ms
85,020 KB
testcase_54 AC 1,403 ms
85,408 KB
testcase_55 AC 1,369 ms
85,228 KB
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 AC 1,363 ms
85,160 KB
testcase_62 AC 1,310 ms
85,204 KB
testcase_63 AC 1,228 ms
85,204 KB
testcase_64 AC 1,322 ms
85,376 KB
testcase_65 AC 1,404 ms
85,200 KB
testcase_66 AC 1,346 ms
85,520 KB
testcase_67 AC 1,390 ms
85,264 KB
testcase_68 AC 1,410 ms
85,224 KB
testcase_69 AC 1,406 ms
84,964 KB
testcase_70 AC 1,281 ms
85,812 KB
testcase_71 AC 1,005 ms
85,228 KB
testcase_72 AC 972 ms
85,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,K=map(int,input().split())
A=list(map(int,input().split()))
C=list(map(int,input().split()))

DP=[[[10**9,-1] for i in range(N)] for j in range(N)]

for i in range(N):
    DP[i][0]=[C[i],C[i]]

for j in range(1,N):
    for i in range(N):
        # DP[i][j]
        # [i,i+j]

        for k in range(j):
            # [i,i+k], [i+k+1,j]
            # DP[i][k], DP[i+k+1][j-k]

            a,b=DP[i][k]
            c,d=DP[(i+k+1)%N][j-k-1]

            #print(j,i,k,a,b,c,d)

            if a==10**9 or c==10**9:
                continue

            if (b<c and c-b>K) or (d<a and a-d>K):
                continue
            else:
                DP[i][j][0]=min(DP[i][j][0],a,c)
                DP[i][j][1]=max(DP[i][j][1],b,d)

            

            
    
S=[0]
for a in A+A:
    S.append(S[-1]+a)

ANS=0
for i in range(N):
    for j in range(N):
        if DP[i][j][1]!=-1:
            ANS=max(ANS,S[i+j+1]-S[i])

print(ANS)
0