답안 #781208

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
781208 2023-07-12T22:51:03 Z NK_ Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
166 ms 16724 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)];
			if (S[i ^ low] == -1 || S[i] > M) S[i] = -1;
		}
		sort(rbegin(S), rend(S));
		while(S.back() == -1) S.pop_back();

		// for(auto x : S) cout << x << " ";
		// cout << endl;

		return S;
	};	

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

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

	cout << ans << nl;

    return 0;
}


# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 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 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 1876 KB Output is correct
2 Correct 39 ms 4428 KB Output is correct
3 Correct 166 ms 16724 KB Output is correct
4 Correct 38 ms 4436 KB Output is correct
5 Correct 5 ms 1236 KB Output is correct
6 Correct 5 ms 724 KB Output is correct
7 Correct 3 ms 1236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 2388 KB Output is correct
2 Correct 14 ms 1748 KB Output is correct
3 Correct 59 ms 8520 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 2 ms 724 KB Output is correct
6 Correct 9 ms 1236 KB Output is correct
7 Correct 2 ms 1236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 3408 KB Output is correct
2 Correct 58 ms 6484 KB Output is correct
3 Correct 58 ms 6372 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 24 ms 6476 KB Output is correct
6 Correct 129 ms 16724 KB Output is correct
7 Correct 11 ms 6484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 121 ms 12624 KB Output is correct
2 Correct 13 ms 1748 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 117 ms 12620 KB Output is correct
7 Correct 2 ms 1236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 1748 KB Output is correct
2 Correct 38 ms 4436 KB Output is correct
3 Correct 5 ms 724 KB Output is correct
4 Correct 4 ms 724 KB Output is correct
5 Correct 29 ms 6484 KB Output is correct
6 Correct 13 ms 1748 KB Output is correct
7 Correct 31 ms 16720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 163 ms 16712 KB Output is correct
2 Correct 14 ms 1876 KB Output is correct
3 Correct 6 ms 724 KB Output is correct
4 Correct 165 ms 16712 KB Output is correct
5 Correct 37 ms 8544 KB Output is correct
6 Correct 9 ms 1356 KB Output is correct
7 Correct 4 ms 2392 KB Output is correct