Submission #29772327


Source Code Expand

#include<bits/stdc++.h>
#define int long long
using namespace std;
template <class T> inline T read(){
	T r=0,f=0;char c=getchar();
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) r=(r<<3)+(r<<1)+(c^48),c=getchar();
	return f?-r:r;
}
const int _=45;
int n,t,a[_],ans;
vector<int> p1,p2;
void dfs(int x,int ed,int sum,vector<int> &V){
	if(sum>t) return;
	if(x>ed){ans=max(ans,sum),V.push_back(sum);return;}
	dfs(x+1,ed,sum,V);
	dfs(x+1,ed,sum+a[x],V);
}
signed main(){
	n=read<int>(),t=read<int>();
	for(int i=1;i<=n;++i) a[i]=read<int>();
	dfs(1,n/2,0,p1),dfs(n/2+1,n,0,p2);
	sort(p2.begin(),p2.end());
	for(auto v:p1) ans=max(ans,v+p2[upper_bound(p2.begin(),p2.end(),t-v)-p2.begin()-1]);
	printf("%lld",ans);
	return 0;
}

Submission Info

Submission Time
Task F - Programming Contest
User Quick_Kk
Language C++ (GCC 9.2.1)
Score 600
Code Size 762 Byte
Status AC
Exec Time 273 ms
Memory 23472 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 4
AC × 35
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All hand_01.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
hand_01.txt AC 8 ms 3416 KiB
random_01.txt AC 2 ms 3480 KiB
random_02.txt AC 2 ms 3544 KiB
random_03.txt AC 2 ms 3544 KiB
random_04.txt AC 3 ms 3572 KiB
random_05.txt AC 4 ms 3492 KiB
random_06.txt AC 2 ms 3496 KiB
random_07.txt AC 2 ms 3632 KiB
random_08.txt AC 2 ms 3592 KiB
random_09.txt AC 2 ms 3600 KiB
random_10.txt AC 2 ms 3540 KiB
random_11.txt AC 2 ms 3552 KiB
random_12.txt AC 2 ms 3696 KiB
random_13.txt AC 3 ms 3432 KiB
random_14.txt AC 2 ms 3568 KiB
random_15.txt AC 2 ms 3560 KiB
random_16.txt AC 2 ms 3484 KiB
random_17.txt AC 2 ms 3468 KiB
random_18.txt AC 3 ms 3428 KiB
random_19.txt AC 2 ms 3412 KiB
random_20.txt AC 3 ms 3564 KiB
random_21.txt AC 3 ms 3636 KiB
random_22.txt AC 2 ms 3564 KiB
random_23.txt AC 2 ms 3520 KiB
random_24.txt AC 2 ms 3572 KiB
random_25.txt AC 2 ms 3500 KiB
random_26.txt AC 125 ms 23420 KiB
random_27.txt AC 273 ms 23472 KiB
random_28.txt AC 3 ms 3548 KiB
random_29.txt AC 3 ms 3504 KiB
random_30.txt AC 2 ms 3588 KiB
sample_01.txt AC 3 ms 3424 KiB
sample_02.txt AC 3 ms 3572 KiB
sample_03.txt AC 2 ms 3492 KiB
sample_04.txt AC 1 ms 3476 KiB