Submission #1357590


Source Code Expand

#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
#define int long long
#define rep(i,a,n) for (int (i)=(a);(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef long double ld;
int a[33];
bool l[33];
vector<int>r,y;
int n,x;
void solve(int i){
	if(i==floor(n/2.0)){
		int sum=0;
		for(int j=0;j<floor(n/2.0);j++){
			if(l[j])
				sum+=a[j];
		}
		r.push_back(sum);
		return;
	}
	l[i]=false;
	solve(i+1);
	l[i]=true;
	solve(i+1);
}
void solve2(int i){
	if(i==n){
		int sum=0;
		for(int j=floor(n/2.0);j<n;j++){
			if(l[j])
				sum+=a[j];
		}
		y.push_back(sum);
		return;
	}
	l[i]=false;
	solve2(i+1);
	l[i]=true;
	solve2(i+1);
}
signed  main() {
	cin>>n>>x;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	solve(0);
	solve2(floor(n/2.0));
	int sum=0;
	for(int i=0;i<r.size();i++){
		int k=lower_bound(y.begin(),y.end(),x-r[i])-y.begin();
		if(k==y.size()) continue;
		while(k<y.size()&&y[k]==x-r[i]){
			sum++;
			k++;
		}
	}
	cout<<sum<<endl;
}

Submission Info

Submission Time
Task C - 無駄なものが嫌いな人
User Thistle
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1214 Byte
Status WA
Exec Time 11 ms
Memory 1528 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 6
WA × 22
Set Name Test Cases
All max_1.txt, max_2.txt, max_3.txt, max_4.txt, pair_1.txt, pair_2.txt, power2_1.txt, power2_2.txt, power2_3.txt, power2_4.txt, power2_5.txt, random_1.txt, random_2.txt, random_3.txt, random_4.txt, random_5.txt, random_6.txt, random_7.txt, random_8.txt, random_9.txt, sample_1.txt, sample_2.txt, sample_3.txt, sample_4.txt, small_1.txt, small_2.txt, small_3.txt, small_4.txt
Case Name Status Exec Time Memory
max_1.txt WA 10 ms 1528 KB
max_2.txt WA 10 ms 1528 KB
max_3.txt WA 11 ms 1528 KB
max_4.txt WA 10 ms 1528 KB
pair_1.txt WA 10 ms 1528 KB
pair_2.txt WA 10 ms 1528 KB
power2_1.txt WA 10 ms 1528 KB
power2_2.txt WA 10 ms 1528 KB
power2_3.txt WA 10 ms 1528 KB
power2_4.txt WA 10 ms 1528 KB
power2_5.txt WA 2 ms 384 KB
random_1.txt WA 7 ms 1148 KB
random_2.txt WA 8 ms 1148 KB
random_3.txt AC 10 ms 1528 KB
random_4.txt WA 10 ms 1528 KB
random_5.txt WA 10 ms 1528 KB
random_6.txt WA 8 ms 1148 KB
random_7.txt WA 10 ms 1528 KB
random_8.txt WA 10 ms 1528 KB
random_9.txt WA 7 ms 1148 KB
sample_1.txt WA 1 ms 256 KB
sample_2.txt AC 1 ms 256 KB
sample_3.txt WA 1 ms 256 KB
sample_4.txt WA 1 ms 256 KB
small_1.txt AC 1 ms 256 KB
small_2.txt AC 1 ms 256 KB
small_3.txt AC 1 ms 256 KB
small_4.txt AC 1 ms 256 KB