답안 #781204

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
781204 2023-07-12T22:38:43 Z NK_ Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
293 ms 20788 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;
		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);
				// cout << i << " " << sum << endl;
			}
		}
		// cout << 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 << " " << amt << endl;
		ans += r + 1;
	}

	cout << ans << nl;

    return 0;
}


# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 224 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 1 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 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 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 23 ms 1980 KB Output is correct
2 Correct 68 ms 5432 KB Output is correct
3 Correct 293 ms 20724 KB Output is correct
4 Correct 68 ms 5316 KB Output is correct
5 Correct 12 ms 1492 KB Output is correct
6 Correct 8 ms 924 KB Output is correct
7 Correct 8 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 2896 KB Output is correct
2 Correct 24 ms 2008 KB Output is correct
3 Correct 119 ms 10540 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 6 ms 956 KB Output is correct
6 Correct 15 ms 1496 KB Output is correct
7 Correct 7 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 3492 KB Output is correct
2 Correct 106 ms 6600 KB Output is correct
3 Correct 103 ms 6500 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 71 ms 6584 KB Output is correct
6 Correct 253 ms 20756 KB Output is correct
7 Correct 45 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 213 ms 12672 KB Output is correct
2 Correct 24 ms 1952 KB Output is correct
3 Correct 8 ms 920 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 7 ms 896 KB Output is correct
6 Correct 211 ms 12708 KB Output is correct
7 Correct 7 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 2008 KB Output is correct
2 Correct 69 ms 5384 KB Output is correct
3 Correct 8 ms 932 KB Output is correct
4 Correct 8 ms 856 KB Output is correct
5 Correct 74 ms 6588 KB Output is correct
6 Correct 24 ms 1976 KB Output is correct
7 Correct 126 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 290 ms 20772 KB Output is correct
2 Correct 24 ms 1960 KB Output is correct
3 Correct 8 ms 928 KB Output is correct
4 Correct 289 ms 20788 KB Output is correct
5 Correct 100 ms 10552 KB Output is correct
6 Correct 15 ms 1492 KB Output is correct
7 Correct 15 ms 316 KB Output is correct