Submission #781205

# Submission time Handle Problem Language Result Execution time Memory
781205 2023-07-12T22:41:03 Z NK_ Ice Hockey World Championship (CEOI15_bobek) C++17
0 / 100
11 ms 17108 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(1 << n, 0);
		for(int i = 1; i < (1<<n); i++) {
			int low = i & -i;
			S[i] = S[i ^ (1 << low)] + A[low];
		}
		return S;
	};	

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

	sort(begin(SA), end(SA));
	sort(begin(SB), end(SB));

	ll ans = 0;
	int r = sz(SB) - 1;
	for(auto x : SA) {
		ll left = M - x;
		while(r >= 0 && SB[r] > left) r--; 
		// cout << left << " " << amt << endl;
		ans += r + 1;
	}

	cout << ans << nl;

    return 0;
}


# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 1492 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 2516 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 2516 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 8788 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 1460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 17108 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -