Submission #658780

#TimeUsernameProblemLanguageResultExecution timeMemory
658780beaconmcIce Hockey World Championship (CEOI15_bobek)C++14
60 / 100
1097 ms112356 KiB
#include <bits/stdc++.h>


typedef long long ll;
using namespace std;


#define FOR(i, x, y) for(ll i=x; i<y; i++)
#define FORNEG(i, x, y) for(ll i=x; i>y; i--)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

ll sus[41];

int main(){
	ll a,b,n,m;
	map<ll, ll> aa, bb;

	cin >> n >> m;
	FOR(i,0,n) cin >> sus[i];

	a = n/2;
	b = (n-1)/2 + 1;

	

	FOR(i,0,1<<a){
		ll cur = 0, temp = 0, tempi = i;
		while (tempi){
			if (tempi&1) temp += sus[cur];
			cur++;
			tempi /=2;
		}
		aa[temp] += 1;
	}



	FOR(i,0,1<<b){
		ll cur = a, temp = 0, tempi = i;
		while (tempi){
			if (tempi&1) temp += sus[cur];
			cur++;
			tempi /=2;
		}

		bb[temp] += 1;
	}


	vector<ll> aaa, bbb;
	vector<ll> aaa2,bbb2;

	ll cur = 0;

	for (auto&i : aa){
		aaa.push_back(i.first);
		aaa2.push_back(i.second);

	}
	cur = 0;

	for (auto&i : bb){
		cur += i.second;
		bbb.push_back(i.first);
		bbb2.push_back(cur);
	}

	ll ans = 0;

	FOR(i,0,aaa.size()){

		if (m-aaa[i] < 0) continue;

		ll lower = upper_bound(bbb.begin(), bbb.end(), m-aaa[i]) - bbb.begin() - 1;

		ans += bbb2[lower] * aaa2[i];
	}
	cout << ans;




}

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:8:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
   70 |  FOR(i,0,aaa.size()){
      |      ~~~~~~~~~~~~~~                
bobek.cpp:70:2: note: in expansion of macro 'FOR'
   70 |  FOR(i,0,aaa.size()){
      |  ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...