結果

問題 No.2329 Nafmo、イカサマをする
ユーザー masa_aamasa_aa
提出日時 2023-05-28 15:49:50
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,500 bytes
コンパイル時間 373 ms
コンパイル使用メモリ 86,948 KB
実行使用メモリ 79,124 KB
最終ジャッジ日時 2023-08-27 13:04:55
合計ジャッジ時間 7,285 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 73 ms
71,416 KB
testcase_04 AC 72 ms
71,228 KB
testcase_05 WA -
testcase_06 AC 73 ms
71,272 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 WA -
testcase_10 AC 73 ms
71,180 KB
testcase_11 WA -
testcase_12 RE -
testcase_13 WA -
testcase_14 AC 71 ms
71,108 KB
testcase_15 AC 70 ms
71,180 KB
testcase_16 RE -
testcase_17 AC 71 ms
71,180 KB
testcase_18 WA -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 75 ms
75,576 KB
testcase_24 AC 70 ms
71,408 KB
testcase_25 WA -
testcase_26 AC 71 ms
71,284 KB
testcase_27 AC 74 ms
75,380 KB
testcase_28 AC 70 ms
71,052 KB
testcase_29 RE -
testcase_30 RE -
testcase_31 AC 73 ms
71,304 KB
testcase_32 RE -
testcase_33 AC 75 ms
75,480 KB
testcase_34 AC 74 ms
75,376 KB
testcase_35 RE -
testcase_36 RE -
testcase_37 AC 79 ms
75,844 KB
testcase_38 AC 76 ms
75,548 KB
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left, bisect_right
# bisect_left(a, x): a[i] >= xとなるような最小のi.
# 昇順ソートされたリストaに昇順を崩さずxを挿入できる位置s(0-index)を返す.
# a = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
# s = bisect_left(a,4), s = 2


n, m, k = map(int, input().split())
a = list(map(int, input().split())) + [0]
if k >= 4:
    0 / 0
if k == 1:
    ans = 0
    for i in a:
        if ans < i <= m:
            ans = i
    print(ans)
elif k == 2:
    b = [x + y for x in a for y in a if x + y <= m]
    print(max(b))

elif k == 3:
    b = [x + y for x in a for y in a for z in a if x + y + z <= m]
    print(max(b))

elif k == 4:
    b = [x + y + z for x in a for y in a for z in a if x + y + z <= m]
    b = list(set(b))
    b.sort()
    ans = 0
    for i in a:
        k = bisect_left(b, m - i + 1)
        if k - 1 >= 0:
            ans = max(ans, b[k - 1] + i)
    print(ans)

elif k == 5:
    b = [x + y + z for x in a for y in a for z in a if x + y + z <= m]
    c = [x + y for x in a for y in a if x + y <= m]
    b = list(set(b))
    b.sort()
    ans = 0
    for i in c:
        k = bisect_left(b, m - i + 1)
        if k - 1 >= 0:
            ans = max(ans, b[k - 1] + i)
    print(ans)


else:
    b = [x + y + z for x in a for y in a for z in a if x + y + z <= m]
    b = list(set(b))
    b.sort()
    ans = 0
    for i in b:
        k = bisect_left(b, m - i + 1)
        if k - 1 >= 0:
            ans = max(ans, b[k - 1] + i)
    print(ans)
0