結果

問題 No.2329 Nafmo、イカサマをする
ユーザー ntudantuda
提出日時 2023-06-10 20:49:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 548 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 87,324 KB
実行使用メモリ 89,532 KB
最終ジャッジ日時 2023-08-31 00:51:06
合計ジャッジ時間 6,081 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,292 KB
testcase_01 AC 71 ms
71,180 KB
testcase_02 AC 73 ms
71,484 KB
testcase_03 AC 76 ms
71,376 KB
testcase_04 AC 74 ms
71,520 KB
testcase_05 AC 73 ms
71,552 KB
testcase_06 AC 72 ms
71,580 KB
testcase_07 AC 73 ms
71,568 KB
testcase_08 AC 83 ms
76,292 KB
testcase_09 AC 75 ms
71,596 KB
testcase_10 AC 78 ms
76,284 KB
testcase_11 AC 76 ms
75,904 KB
testcase_12 AC 74 ms
71,324 KB
testcase_13 AC 78 ms
76,076 KB
testcase_14 AC 74 ms
71,172 KB
testcase_15 AC 79 ms
76,208 KB
testcase_16 AC 74 ms
71,424 KB
testcase_17 AC 72 ms
71,408 KB
testcase_18 AC 74 ms
71,320 KB
testcase_19 AC 87 ms
77,256 KB
testcase_20 AC 79 ms
76,080 KB
testcase_21 AC 80 ms
76,264 KB
testcase_22 AC 79 ms
76,380 KB
testcase_23 AC 82 ms
76,040 KB
testcase_24 AC 81 ms
76,200 KB
testcase_25 AC 81 ms
76,348 KB
testcase_26 AC 84 ms
76,384 KB
testcase_27 AC 79 ms
76,088 KB
testcase_28 AC 80 ms
76,076 KB
testcase_29 AC 86 ms
76,460 KB
testcase_30 AC 79 ms
76,380 KB
testcase_31 AC 80 ms
76,256 KB
testcase_32 AC 75 ms
71,460 KB
testcase_33 AC 80 ms
76,220 KB
testcase_34 AC 81 ms
76,080 KB
testcase_35 AC 81 ms
76,460 KB
testcase_36 AC 91 ms
76,692 KB
testcase_37 AC 81 ms
76,352 KB
testcase_38 AC 111 ms
89,080 KB
testcase_39 AC 95 ms
78,232 KB
testcase_40 AC 104 ms
83,284 KB
testcase_41 AC 135 ms
89,532 KB
testcase_42 AC 102 ms
83,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M,K = map(int,input().split())
A = list(map(int,input().split())) + [0]

S = [set() for _ in range(7)]
S[0] = {0}

for i in range(1,4):
    for a in A:
        for b in S[i-1]:
            d = a + b
            if d <= M:
                S[i].add(d)

if K < 4:
    print(max(S[K]))
    exit()

i = K // 2
j = K - i
S1 = list(S[i])
S1.sort()
S2 = list(S[j])
S2.sort(reverse = True)
NS2 = len(S2)
i = 0
ans = 0
for a in S1:
    while i < NS2 and a + S2[i] > M:
        i += 1
    if i == NS2:
        break
    ans = max(ans,a + S2[i])

print(ans)
0