結果
問題 | No.783 門松計画 |
ユーザー |
![]() |
提出日時 | 2024-02-03 03:21:14 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,288 bytes |
コンパイル時間 | 167 ms |
コンパイル使用メモリ | 82,968 KB |
実行使用メモリ | 85,688 KB |
最終ジャッジ日時 | 2024-09-28 10:44:54 |
合計ジャッジ時間 | 4,296 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 TLE * 1 -- * 16 |
ソースコード
N,C=map(int,input().split())L=list(map(int,input().split()))W=list(map(int,input().split()))def calc(a,b,cost):ANS=0if a==b==0:for i in range(N):if W[i]<=cost:ANS=max(ANS,L[i]+calc(0,L[i],cost-W[i]))return ANSif a==0:for i in range(N):if L[i]!=b and W[i]<=cost:ANS=max(ANS,L[i]+calc(b,L[i],cost-W[i]))return ANSif a<b:for i in range(N):if W[i]<=cost and L[i]<b and L[i]!=a:ANS=max(ANS,L[i]+calc(b,L[i],cost-W[i]))return ANSelse:for i in range(N):if W[i]<=cost and L[i]>b and L[i]!=a:ANS=max(ANS,L[i]+calc(b,L[i],cost-W[i]))return ANSif len(set(sorted(L)))<=2:print(0)else:ANS=0for i in range(N):for j in range(N):for k in range(N):if L[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i] and W[i]+W[j]+W[k]<=C:if L[i]<L[j] and L[j]>L[k]:ANS=max(ANS,L[i]+L[j]+L[k]+calc(L[j],L[k],C-W[i]-W[j]-W[k]))if L[i]>L[j] and L[j]<L[k]:ANS=max(ANS,L[i]+L[j]+L[k]+calc(L[j],L[k],C-W[i]-W[j]-W[k]))print(ANS)