結果

問題 No.2329 Nafmo、イカサマをする
コンテスト
ユーザー とりゐ
提出日時 2023-05-28 14:19:21
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 412 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 266 ms
コンパイル使用メモリ 85,376 KB
実行使用メモリ 89,984 KB
最終ジャッジ日時 2026-06-01 19:16:15
合計ジャッジ時間 4,111 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n,m,k=map(int,input().split())
a=list(map(int,input().split()))

k1=k//2
k2=k-k1

def get(s):
  if s==0:
    return [0]
  res=get(s-1)
  new=set(res)
  for i in range(n):
    for j in res:
      if a[i]+j<=m:
        new.add(a[i]+j)
  return list(new)

res1=get(k1)
res2=get(k2)
res1.sort()
res2.sort()
ans=0
idx=len(res2)-1
for i in res1:
  while i+res2[idx]>m:
    idx-=1
  ans=max(ans,i+res2[idx])

print(ans)
0