Submission #781196

# Submission time Handle Problem Language Result Execution time Memory
781196 2023-07-12T22:29:04 Z NK_ Ice Hockey World Championship (CEOI15_bobek) C++17
20 / 100
167 ms 10504 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);
	
	// LITERALLY JUST MITM

	int N; ll M; cin >> N >> M;

	int a = min(20, N), b = N - a;

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

	V<int> SA, SB;
	auto get = [&](const V<int>& X) {
		int n = sz(X);
		V<int> 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);
		}
		return S;
	};	

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

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

	cout << ans << nl;

    return 0;
}


# Verdict Execution time Memory Grader output
1 Correct 1 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 984 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 71 ms 4516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 87 ms 4572 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 100 ms 4500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 97 ms 4620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 128 ms 8476 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 4532 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 167 ms 10504 KB Output isn't correct
2 Halted 0 ms 0 KB -