結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー roarisroaris
提出日時 2019-12-12 14:09:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,226 bytes
コンパイル時間 409 ms
コンパイル使用メモリ 87,140 KB
実行使用メモリ 291,980 KB
最終ジャッジ日時 2023-09-07 05:53:45
合計ジャッジ時間 30,708 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,248 KB
testcase_01 AC 81 ms
71,400 KB
testcase_02 AC 76 ms
71,404 KB
testcase_03 AC 76 ms
71,332 KB
testcase_04 AC 79 ms
75,168 KB
testcase_05 AC 91 ms
76,060 KB
testcase_06 AC 89 ms
76,284 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 895 ms
195,956 KB
testcase_16 AC 1,631 ms
267,576 KB
testcase_17 AC 305 ms
104,332 KB
testcase_18 WA -
testcase_19 AC 1,405 ms
250,840 KB
testcase_20 AC 387 ms
113,412 KB
testcase_21 AC 196 ms
91,744 KB
testcase_22 AC 292 ms
109,548 KB
testcase_23 AC 103 ms
79,576 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 1,849 ms
287,756 KB
testcase_28 AC 1,849 ms
287,064 KB
testcase_29 AC 1,931 ms
289,332 KB
testcase_30 AC 1,910 ms
287,116 KB
testcase_31 WA -
testcase_32 AC 1,839 ms
290,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
D = list(map(int, input().split()))
D.sort()
dp = [[-1]*(N+1) for _ in range(N+1)]
dp[0][0] = (N, 0)

for i in range(N+1):
    for j in range(N+1):
        if i+j>N:
            break
        
        if i==0 and j==0:
            continue
        
        if i>0:
            idx1, solved1 = dp[i-1][j]
            
        if j>0:
            idx2, solved2 = dp[i][j-1]
            
        mark = bisect_right(D, A[i]+B[j])
        
        if i!=0 and (j==0 or (solved1==solved2 and idx1>idx2) or solved1>solved2):
            if mark==0 or idx1==0:
                dp[i][j] = (idx1, solved1)
            else:
                if mark-1==idx1:
                    dp[i][j] = (idx1-1, solved1+1)
                else:
                    dp[i][j] = (mark-1, solved1+1)
        else:
            if mark==0 or idx2==0:
                dp[i][j] = (idx2, solved2)
            else:
                if mark-1==idx2:
                    dp[i][j] = (idx2-1, solved2+1)
                else:
                    dp[i][j] = (mark-1, solved2+1)

ans = 0

for i in range(N+1):
    ans = max(ans, dp[i][N-i][1])

print(ans)
0