結果

問題 No.2423 Merge Stones
ユーザー titiatitia
提出日時 2023-08-24 01:04:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,231 ms / 4,000 ms
コード長 838 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 87,224 KB
実行使用メモリ 77,900 KB
最終ジャッジ日時 2023-08-24 01:05:51
合計ジャッジ時間 67,045 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,224 KB
testcase_01 AC 87 ms
76,516 KB
testcase_02 AC 83 ms
76,376 KB
testcase_03 AC 83 ms
76,316 KB
testcase_04 AC 74 ms
71,128 KB
testcase_05 AC 83 ms
76,488 KB
testcase_06 AC 84 ms
76,332 KB
testcase_07 AC 81 ms
76,412 KB
testcase_08 AC 79 ms
71,016 KB
testcase_09 AC 75 ms
71,352 KB
testcase_10 AC 86 ms
76,408 KB
testcase_11 AC 1,203 ms
77,808 KB
testcase_12 AC 359 ms
77,840 KB
testcase_13 AC 1,179 ms
77,792 KB
testcase_14 AC 807 ms
77,604 KB
testcase_15 AC 926 ms
77,844 KB
testcase_16 AC 1,100 ms
77,664 KB
testcase_17 AC 853 ms
77,440 KB
testcase_18 AC 1,072 ms
77,808 KB
testcase_19 AC 361 ms
77,832 KB
testcase_20 AC 824 ms
77,792 KB
testcase_21 AC 1,180 ms
77,764 KB
testcase_22 AC 804 ms
77,768 KB
testcase_23 AC 922 ms
77,660 KB
testcase_24 AC 923 ms
77,696 KB
testcase_25 AC 895 ms
77,592 KB
testcase_26 AC 905 ms
77,536 KB
testcase_27 AC 967 ms
77,664 KB
testcase_28 AC 1,207 ms
77,812 KB
testcase_29 AC 1,101 ms
77,648 KB
testcase_30 AC 849 ms
77,764 KB
testcase_31 AC 815 ms
77,736 KB
testcase_32 AC 1,210 ms
77,768 KB
testcase_33 AC 929 ms
77,780 KB
testcase_34 AC 967 ms
77,664 KB
testcase_35 AC 843 ms
77,616 KB
testcase_36 AC 821 ms
77,788 KB
testcase_37 AC 929 ms
77,900 KB
testcase_38 AC 926 ms
77,688 KB
testcase_39 AC 1,207 ms
77,624 KB
testcase_40 AC 1,099 ms
77,500 KB
testcase_41 AC 947 ms
77,728 KB
testcase_42 AC 1,210 ms
77,744 KB
testcase_43 AC 357 ms
77,660 KB
testcase_44 AC 1,213 ms
77,788 KB
testcase_45 AC 913 ms
77,728 KB
testcase_46 AC 940 ms
77,820 KB
testcase_47 AC 925 ms
77,652 KB
testcase_48 AC 923 ms
77,728 KB
testcase_49 AC 356 ms
77,592 KB
testcase_50 AC 358 ms
77,588 KB
testcase_51 AC 1,101 ms
77,680 KB
testcase_52 AC 1,083 ms
77,676 KB
testcase_53 AC 1,197 ms
77,760 KB
testcase_54 AC 1,107 ms
77,796 KB
testcase_55 AC 1,208 ms
77,864 KB
testcase_56 AC 1,093 ms
77,788 KB
testcase_57 AC 1,096 ms
77,684 KB
testcase_58 AC 1,213 ms
77,652 KB
testcase_59 AC 1,207 ms
77,824 KB
testcase_60 AC 1,102 ms
77,864 KB
testcase_61 AC 1,206 ms
77,864 KB
testcase_62 AC 1,209 ms
77,872 KB
testcase_63 AC 1,203 ms
77,644 KB
testcase_64 AC 1,207 ms
77,704 KB
testcase_65 AC 1,201 ms
77,576 KB
testcase_66 AC 1,220 ms
77,812 KB
testcase_67 AC 1,215 ms
77,812 KB
testcase_68 AC 1,231 ms
77,732 KB
testcase_69 AC 1,211 ms
77,756 KB
testcase_70 AC 1,203 ms
77,816 KB
testcase_71 AC 1,205 ms
77,772 KB
testcase_72 AC 1,210 ms
77,652 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=[[0]*N for i in range(N)]

for i in range(N):
    DP[i][0]=1<<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=DP[i][k]
            b=DP[(i+k+1)%N][j-k-1]

            ANS=0

            for l in range(K+1):
                ANS|=(a&(b<<l))
                ANS|=(a&(b>>l))
                ANS|=(b&(a<<l))
                ANS|=(b&(a>>l))

            DP[i][j]|=ANS
            
    
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]!=0:
            ANS=max(ANS,S[i+j+1]-S[i])

print(ANS)
0