Submission #85967

# Submission time Handle Problem Language Result Execution time Memory
85967 2018-11-23T13:54:33 Z Nordway Ice Hockey World Championship (CEOI15_bobek) C++14
20 / 100
244 ms 9092 KB
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define boost ios_base::sync_with_stdio(0),cin.tie(0)
#define FILE "divide"

using namespace std;


typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

const int mod=1e9+7;
const int inf=1e9;
const ll INF=1e18;
const ld pi=acos(-1);
const int N=41;

ll a[N];

int main(){
	/*freopen(FILE".in","r",stdin);
	freopen(FILE".out","w",stdout);*/
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int fn=(n+1)/2;
	int sn=n-fn;
	vector<ll>v;
	for(int mask=0;mask<(1<<fn);mask++){
		ll sum=0;
		for(int i=0;i<fn;i++){
			if((mask>>i)&1)sum+=a[i];
		}
		if(sum>m)continue;
		v.pb(sum);
	}
	sort(all(v));
	int ans=0;
	for(int mask=0;mask<(1<<sn);mask++){
		ll sum=0;
		for(int i=0;i<sn;i++){
			if((mask>>i)&1)sum+=a[fn+i];
		}
		if(sum>m)continue;
		int pos=up_b(all(v),m-sum)-v.begin();
		ans+=pos;
	}
	cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 584 KB Output is correct
3 Correct 2 ms 584 KB Output is correct
4 Correct 2 ms 584 KB Output is correct
5 Correct 2 ms 684 KB Output is correct
6 Correct 2 ms 684 KB Output is correct
7 Correct 2 ms 684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 712 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 1924 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 1924 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 86 ms 2948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 179 ms 9024 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 9024 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 244 ms 9092 KB Output isn't correct
2 Halted 0 ms 0 KB -