P2736 [USACO3.4]“破锣摇滚”乐队 Raucous Rockers

P2736 [USACO3.4]“破锣摇滚”乐队 Raucous Rockers

死小的数据范围

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,m,t;
int a[50001];
int ans=0;
void dfs(int ncd,int ns,int re,int ch){
	if(ncd==m+1||ns>n){
		ans=max(ch,ans);
		return ;
	}
	if(ch==n){
		cout<<n;
		exit(0);
	}
	if(re>=a[ns]){
		dfs(ncd,ns+1,re-a[ns],ch+1);
	}else{
		dfs(ncd+1,ns,t,ch);
	}
	dfs(ncd,ns+1,re,ch);
}
int main(){
	scanf("%d%d%d",&n,&t,&m);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]); 
	} 
	dfs(1,1,t,0);
	cout<<ans<<endl;
	return 0;
}
posted @ 2021-07-11 10:18  Simex  阅读(37)  评论(0编辑  收藏  举报