結果

問題 No.2329 Nafmo、イカサマをする
ユーザー masa_aamasa_aa
提出日時 2023-05-28 15:48:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,500 bytes
コンパイル時間 424 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 116,492 KB
最終ジャッジ日時 2023-08-27 13:02:25
合計ジャッジ時間 5,875 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,424 KB
testcase_01 AC 76 ms
75,324 KB
testcase_02 AC 75 ms
71,136 KB
testcase_03 AC 73 ms
71,476 KB
testcase_04 AC 74 ms
71,356 KB
testcase_05 WA -
testcase_06 AC 73 ms
71,232 KB
testcase_07 RE -
testcase_08 AC 87 ms
75,900 KB
testcase_09 WA -
testcase_10 AC 71 ms
71,456 KB
testcase_11 WA -
testcase_12 AC 76 ms
75,752 KB
testcase_13 WA -
testcase_14 AC 71 ms
71,352 KB
testcase_15 AC 74 ms
71,364 KB
testcase_16 RE -
testcase_17 AC 74 ms
71,596 KB
testcase_18 WA -
testcase_19 AC 88 ms
80,516 KB
testcase_20 RE -
testcase_21 AC 80 ms
75,544 KB
testcase_22 AC 79 ms
75,700 KB
testcase_23 AC 77 ms
75,604 KB
testcase_24 AC 72 ms
71,468 KB
testcase_25 WA -
testcase_26 AC 73 ms
71,272 KB
testcase_27 AC 76 ms
75,384 KB
testcase_28 AC 72 ms
71,256 KB
testcase_29 AC 89 ms
76,772 KB
testcase_30 AC 80 ms
75,632 KB
testcase_31 AC 74 ms
71,120 KB
testcase_32 AC 77 ms
75,264 KB
testcase_33 AC 79 ms
75,440 KB
testcase_34 AC 76 ms
75,320 KB
testcase_35 RE -
testcase_36 AC 97 ms
80,012 KB
testcase_37 AC 82 ms
75,856 KB
testcase_38 AC 80 ms
75,784 KB
testcase_39 RE -
testcase_40 AC 123 ms
103,592 KB
testcase_41 AC 162 ms
116,492 KB
testcase_42 AC 124 ms
103,396 KB
権限があれば一括ダウンロードができます

ソースコード

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 == 5:
    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