답안 #710627

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
710627 2023-03-15T12:40:12 Z WonderfulWhale Ice Hockey World Championship (CEOI15_bobek) C++17
50 / 100
1000 ms 120224 KB
#include<bits/stdc++.h>
using namespace std;

#define int int64_t
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

map<int, int> M;
map<int, int> M2;
set<pii> S;

int tab[49];

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, Sum;
	cin >> n >> Sum;
	for(int i=0;i<n;i++) {
		cin >> tab[i];
	}
	int m = n/2;
	if(n==1) {
		if(tab[0]<=Sum) {
			cout << "1\n";
		} else {
			cout << "0\n";
		}
		return 0;
	}
	int m2 = n-m;
	for(int i=0;i<(1<<m);i++) {
		int s = 0;
		for(int j=0;j<m;j++) {
			if(i&(1<<j)) {
				s+=tab[j];
			}
		}
		M[s]++;
	}
	for(int i=0;i<(1<<m2);i++) {
		int s = 0;
		for(int j=m;j<n;j++) {
			if(i&(1<<(j-m))) {
				s+=tab[j];
			}
		}
		M2[s]++;
	}
	int s = 0;
	for(pii x:M2) {
		s += x.nd;
		S.insert({x.st, s});
	}
	int ans = 0;
	for(pii x:M) {
		if(x.st>Sum) continue;
		int val = Sum-x.st;
		auto it = S.upper_bound({val, 1e18});
		if(it==S.begin()) continue;
		it--;
		ans += x.nd*(*it).nd;
	}
	cout << ans << "\n";

}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 2472 KB Output is correct
2 Correct 332 ms 33108 KB Output is correct
3 Execution timed out 1085 ms 55284 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 4424 KB Output is correct
2 Correct 89 ms 12732 KB Output is correct
3 Correct 149 ms 2128 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 7 ms 324 KB Output is correct
6 Correct 45 ms 5048 KB Output is correct
7 Correct 82 ms 12452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 225 ms 29064 KB Output is correct
2 Correct 366 ms 28908 KB Output is correct
3 Correct 343 ms 27332 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 63 ms 304 KB Output is correct
6 Correct 405 ms 3872 KB Output is correct
7 Correct 693 ms 82488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1073 ms 120224 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 128 ms 20816 KB Output is correct
2 Correct 471 ms 49440 KB Output is correct
3 Correct 34 ms 6348 KB Output is correct
4 Correct 33 ms 6468 KB Output is correct
5 Correct 69 ms 316 KB Output is correct
6 Correct 141 ms 20808 KB Output is correct
7 Execution timed out 1084 ms 90772 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1078 ms 88120 KB Time limit exceeded
2 Halted 0 ms 0 KB -