Submission #781206

# Submission time Handle Problem Language Result Execution time Memory
781206 2023-07-12T22:43:58 Z NK_ Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
182 ms 16736 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 ^ low] + X[__lg(low)];
			// cout << i << " " << __lg(low) << " " << S[i] << endl;
		}
		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 << " " << r << endl;
		ans += r + 1;
	}

	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 0 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 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 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 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1748 KB Output is correct
2 Correct 40 ms 4436 KB Output is correct
3 Correct 181 ms 16728 KB Output is correct
4 Correct 43 ms 4440 KB Output is correct
5 Correct 5 ms 1236 KB Output is correct
6 Correct 4 ms 724 KB Output is correct
7 Correct 9 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 2388 KB Output is correct
2 Correct 14 ms 1748 KB Output is correct
3 Correct 64 ms 8532 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 2 ms 796 KB Output is correct
6 Correct 8 ms 1236 KB Output is correct
7 Correct 10 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 3284 KB Output is correct
2 Correct 63 ms 6484 KB Output is correct
3 Correct 59 ms 6484 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 25 ms 6484 KB Output is correct
6 Correct 134 ms 16724 KB Output is correct
7 Correct 65 ms 6468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 126 ms 12628 KB Output is correct
2 Correct 13 ms 1876 KB Output is correct
3 Correct 4 ms 724 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 3 ms 724 KB Output is correct
6 Correct 120 ms 12624 KB Output is correct
7 Correct 8 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 1748 KB Output is correct
2 Correct 39 ms 4444 KB Output is correct
3 Correct 5 ms 724 KB Output is correct
4 Correct 4 ms 724 KB Output is correct
5 Correct 32 ms 6488 KB Output is correct
6 Correct 14 ms 1748 KB Output is correct
7 Correct 161 ms 16732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 173 ms 16732 KB Output is correct
2 Correct 13 ms 1748 KB Output is correct
3 Correct 4 ms 724 KB Output is correct
4 Correct 182 ms 16736 KB Output is correct
5 Correct 42 ms 8532 KB Output is correct
6 Correct 9 ms 1236 KB Output is correct
7 Correct 18 ms 2388 KB Output is correct