Submission #87872

# Submission time Handle Problem Language Result Execution time Memory
87872 2018-12-03T00:07:56 Z shoemakerjo Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
463 ms 21688 KB
#include <bits/stdc++.h>

using namespace std;
#define ll long long

int n;
ll m;

vector<ll> lsums, rsums;
ll ans = 0LL;

ll nums[50];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> nums[i];
	}

	int mid = n/2;

	for (int mask = 0; mask < (1 << mid); mask++) {
		ll sum = 0LL;
		for (int i = 1; i <= mid; i++) {
			if (mask & (1 << (i-1))) {
				sum += nums[i];
			}
		}
		lsums.push_back(sum);
	}

	int onum = n-mid;
	for (int mask = 0; mask < (1 << onum); mask++) {
		ll sum = 0LL;

		for (int i = mid+1; i <= n; i++) {
			if (mask & (1 << (i - mid-1))) {
				sum += nums[i];
			}
		}
		rsums.push_back(sum);
	}

	sort(lsums.begin(), lsums.end());
	sort(rsums.begin(), rsums.end());

	for (ll val : lsums) {
		ans += upper_bound(rsums.begin(), rsums.end(), 
			m-val) - rsums.begin() + 0LL;
	}

	cout << ans << endl;



}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 468 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 3 ms 520 KB Output is correct
4 Correct 3 ms 524 KB Output is correct
5 Correct 2 ms 532 KB Output is correct
6 Correct 3 ms 588 KB Output is correct
7 Correct 2 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 768 KB Output is correct
2 Correct 2 ms 768 KB Output is correct
3 Correct 2 ms 768 KB Output is correct
4 Correct 2 ms 768 KB Output is correct
5 Correct 2 ms 768 KB Output is correct
6 Correct 3 ms 768 KB Output is correct
7 Correct 2 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 768 KB Output is correct
2 Correct 2 ms 768 KB Output is correct
3 Correct 2 ms 768 KB Output is correct
4 Correct 2 ms 768 KB Output is correct
5 Correct 3 ms 768 KB Output is correct
6 Correct 2 ms 768 KB Output is correct
7 Correct 2 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 2532 KB Output is correct
2 Correct 107 ms 5856 KB Output is correct
3 Correct 463 ms 21220 KB Output is correct
4 Correct 108 ms 21220 KB Output is correct
5 Correct 20 ms 21220 KB Output is correct
6 Correct 13 ms 21220 KB Output is correct
7 Correct 24 ms 21220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 21220 KB Output is correct
2 Correct 39 ms 21220 KB Output is correct
3 Correct 187 ms 21220 KB Output is correct
4 Correct 2 ms 21220 KB Output is correct
5 Correct 11 ms 21220 KB Output is correct
6 Correct 25 ms 21220 KB Output is correct
7 Correct 25 ms 21220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 75 ms 21220 KB Output is correct
2 Correct 159 ms 21220 KB Output is correct
3 Correct 155 ms 21220 KB Output is correct
4 Correct 2 ms 21220 KB Output is correct
5 Correct 107 ms 21220 KB Output is correct
6 Correct 395 ms 21512 KB Output is correct
7 Correct 147 ms 21512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 324 ms 21512 KB Output is correct
2 Correct 37 ms 21512 KB Output is correct
3 Correct 37 ms 21512 KB Output is correct
4 Correct 2 ms 21512 KB Output is correct
5 Correct 11 ms 21512 KB Output is correct
6 Correct 313 ms 21512 KB Output is correct
7 Correct 24 ms 21512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 21512 KB Output is correct
2 Correct 104 ms 21512 KB Output is correct
3 Correct 13 ms 21512 KB Output is correct
4 Correct 13 ms 21512 KB Output is correct
5 Correct 115 ms 21512 KB Output is correct
6 Correct 36 ms 21512 KB Output is correct
7 Correct 459 ms 21512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 442 ms 21512 KB Output is correct
2 Correct 38 ms 21512 KB Output is correct
3 Correct 14 ms 21512 KB Output is correct
4 Correct 460 ms 21688 KB Output is correct
5 Correct 160 ms 21688 KB Output is correct
6 Correct 26 ms 21688 KB Output is correct
7 Correct 49 ms 21688 KB Output is correct