Submission #1111167

# Submission time Handle Problem Language Result Execution time Memory
1111167 2024-11-11T15:38:18 Z Ghulam_Junaid Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
327 ms 20904 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
const ll N = 42;
ll n, m, a[N];
 
int main(){
	cin >> n >> m;
	for (ll i=0; i<n; i++)
		cin >> a[i];
 
	ll x = n / 2;
	vector<ll> left, right;
 
	for (ll mask = 0; mask < (1<<x); mask ++){
		ll sm = 0;
		for (ll i = 0; i < x; i++){
			if ((1 << i) & mask){
				sm += a[i];
			}
		}
		left.push_back(sm);
	}
 
	x += n%2;
	for (ll mask = 0; mask < (1<<x); mask ++){
		ll sm = 0;
		for (ll i = 0; i < x; i++){
			if ((1 << i) & mask){
				sm += a[i + n / 2]; 
			}
		}
		right.push_back(sm);
	}
 
	sort(left.begin(), left.end());
	sort(right.begin(), right.end());
 
	ll ans = 0;
	for (ll x : left){
		ll rem = m - x;
		if (rem < 0)
			break;
 
		ll ub = upper_bound(right.begin(), right.end(), rem) - right.begin();
		ans += ub;
	}
 
	cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 440 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 436 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 500 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 2120 KB Output is correct
2 Correct 74 ms 6592 KB Output is correct
3 Correct 312 ms 20904 KB Output is correct
4 Correct 77 ms 6464 KB Output is correct
5 Correct 14 ms 1480 KB Output is correct
6 Correct 9 ms 972 KB Output is correct
7 Correct 16 ms 1584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 2768 KB Output is correct
2 Correct 27 ms 2124 KB Output is correct
3 Correct 126 ms 10528 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 7 ms 1100 KB Output is correct
6 Correct 18 ms 1648 KB Output is correct
7 Correct 16 ms 1480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 59 ms 4680 KB Output is correct
2 Correct 116 ms 6632 KB Output is correct
3 Correct 116 ms 6716 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 90 ms 6716 KB Output is correct
6 Correct 282 ms 20904 KB Output is correct
7 Correct 104 ms 8772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 240 ms 12852 KB Output is correct
2 Correct 26 ms 2120 KB Output is correct
3 Correct 9 ms 1140 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 8 ms 1088 KB Output is correct
6 Correct 229 ms 12744 KB Output is correct
7 Correct 17 ms 1564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 2120 KB Output is correct
2 Correct 84 ms 6444 KB Output is correct
3 Correct 11 ms 972 KB Output is correct
4 Correct 9 ms 972 KB Output is correct
5 Correct 80 ms 6716 KB Output is correct
6 Correct 26 ms 2124 KB Output is correct
7 Correct 287 ms 20900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 326 ms 20900 KB Output is correct
2 Correct 28 ms 2124 KB Output is correct
3 Correct 10 ms 972 KB Output is correct
4 Correct 327 ms 20776 KB Output is correct
5 Correct 112 ms 10688 KB Output is correct
6 Correct 20 ms 1480 KB Output is correct
7 Correct 37 ms 3008 KB Output is correct