結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー roarisroaris
提出日時 2019-12-12 14:18:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,891 ms / 2,500 ms
コード長 1,226 bytes
コンパイル時間 1,199 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 288,928 KB
最終ジャッジ日時 2023-09-07 06:06:43
合計ジャッジ時間 26,990 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,196 KB
testcase_01 AC 72 ms
71,384 KB
testcase_02 AC 73 ms
71,244 KB
testcase_03 AC 72 ms
71,244 KB
testcase_04 AC 80 ms
75,392 KB
testcase_05 AC 90 ms
76,196 KB
testcase_06 AC 87 ms
76,456 KB
testcase_07 AC 99 ms
77,100 KB
testcase_08 AC 125 ms
78,480 KB
testcase_09 AC 106 ms
77,564 KB
testcase_10 AC 99 ms
77,168 KB
testcase_11 AC 1,274 ms
249,588 KB
testcase_12 AC 1,233 ms
253,348 KB
testcase_13 AC 1,151 ms
234,492 KB
testcase_14 AC 261 ms
97,472 KB
testcase_15 AC 878 ms
196,968 KB
testcase_16 AC 1,526 ms
267,028 KB
testcase_17 AC 282 ms
104,704 KB
testcase_18 AC 1,618 ms
275,264 KB
testcase_19 AC 1,352 ms
251,280 KB
testcase_20 AC 386 ms
113,120 KB
testcase_21 AC 194 ms
91,688 KB
testcase_22 AC 281 ms
109,096 KB
testcase_23 AC 105 ms
79,592 KB
testcase_24 AC 880 ms
202,712 KB
testcase_25 AC 1,782 ms
288,856 KB
testcase_26 AC 1,694 ms
286,536 KB
testcase_27 AC 1,650 ms
287,824 KB
testcase_28 AC 1,752 ms
288,524 KB
testcase_29 AC 1,871 ms
288,928 KB
testcase_30 AC 1,891 ms
286,696 KB
testcase_31 AC 1,207 ms
284,984 KB
testcase_32 AC 1,781 ms
286,384 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