답안 #781197

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
781197 2023-07-12T22:29:32 Z NK_ Ice Hockey World Championship (CEOI15_bobek) C++17
40 / 100
178 ms 20828 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<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);
		}
		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;
}


# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 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 8 ms 1364 KB Output is correct
2 Correct 4 ms 600 KB Output is correct
3 Correct 8 ms 876 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 4 ms 856 KB Output is correct
6 Correct 72 ms 8648 KB Output is correct
7 Correct 8 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 8636 KB Output is correct
2 Correct 15 ms 856 KB Output is correct
3 Correct 4 ms 868 KB Output is correct
4 Correct 4 ms 468 KB Output is correct
5 Correct 68 ms 4448 KB Output is correct
6 Correct 9 ms 1492 KB Output is correct
7 Correct 8 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 96 ms 8700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 86 ms 8748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 88 ms 8972 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 133 ms 16656 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 83 ms 8636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 178 ms 20828 KB Output isn't correct
2 Halted 0 ms 0 KB -