Submission #781202

# Submission time Handle Problem Language Result Execution time Memory
781202 2023-07-12T22:37:03 Z NK_ Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
344 ms 20796 KB
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>

using namespace std;

#define nl '\n'
#define sz(x) int(x.size())

using ll = long long;

template<class T> using V = vector<T>;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	
	int N; ll M; cin >> N >> M;

	int a = N / 2, b = N - a;

	V<ll> A(a), B(b);
	for(auto& x : A) cin >> x;
	for(auto& x : B) cin >> x;

	V<ll> SA, SB;
	auto get = [&](const V<ll>& X) {
		int n = sz(X);
		V<ll> S;
		for(int i = 0; i < (1<<n); i++) {
			ll sum = 0;
			for(int b = 0; b < n; b++) if ((i >> b) & 1) sum += X[b];
			if (sum <= M) {
				S.push_back(sum);
				// cout << i << " " << sum << endl;
			}
		}
		// cout << endl;
		return S;
	};	

	SA = get(A);
	SB = get(B);

	sort(begin(SA), end(SA));
	sort(begin(SB), end(SB));
	
	ll ans = 0;
	for(auto x : SA) {
		ll left = M - x;
		int amt = upper_bound(begin(SB), end(SB), left) - begin(SB);
		// cout << left << " " << amt << endl;
		ans += amt;
	}

	cout << ans << nl;

    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 232 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1984 KB Output is correct
2 Correct 76 ms 5444 KB Output is correct
3 Correct 344 ms 20724 KB Output is correct
4 Correct 78 ms 5728 KB Output is correct
5 Correct 13 ms 1600 KB Output is correct
6 Correct 8 ms 984 KB Output is correct
7 Correct 8 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 2820 KB Output is correct
2 Correct 26 ms 2008 KB Output is correct
3 Correct 129 ms 10576 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 6 ms 984 KB Output is correct
6 Correct 16 ms 1492 KB Output is correct
7 Correct 8 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 3536 KB Output is correct
2 Correct 111 ms 6572 KB Output is correct
3 Correct 111 ms 6576 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 73 ms 6524 KB Output is correct
6 Correct 280 ms 20768 KB Output is correct
7 Correct 46 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 229 ms 12732 KB Output is correct
2 Correct 25 ms 1900 KB Output is correct
3 Correct 9 ms 984 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 6 ms 964 KB Output is correct
6 Correct 240 ms 12856 KB Output is correct
7 Correct 8 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 2008 KB Output is correct
2 Correct 74 ms 5408 KB Output is correct
3 Correct 8 ms 856 KB Output is correct
4 Correct 9 ms 984 KB Output is correct
5 Correct 82 ms 6600 KB Output is correct
6 Correct 24 ms 2008 KB Output is correct
7 Correct 125 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 311 ms 20788 KB Output is correct
2 Correct 31 ms 1896 KB Output is correct
3 Correct 9 ms 968 KB Output is correct
4 Correct 323 ms 20796 KB Output is correct
5 Correct 104 ms 10552 KB Output is correct
6 Correct 16 ms 1592 KB Output is correct
7 Correct 15 ms 212 KB Output is correct