Submission #710634

# Submission time Handle Problem Language Result Execution time Memory
710634 2023-03-15T12:46:24 Z WonderfulWhale Ice Hockey World Championship (CEOI15_bobek) C++17
60 / 100
1000 ms 115324 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;

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 << "2\n";
		} else {
			cout << "1\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;
	auto it = M2.begin();
	int ans = 0;
	auto ite = M2.end();
	for(pii x:M) {
		x.st = -x.st;
		int val = Sum-x.st;
		while(it!=ite&&(*it).st<=val) {
			s += (*it).nd;
			it++;
		}
		ans += x.nd*s;
	}
	cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 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
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 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 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory 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 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 1732 KB Output is correct
2 Correct 227 ms 21988 KB Output is correct
3 Execution timed out 1086 ms 55700 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 47 ms 2968 KB Output is correct
2 Correct 58 ms 7980 KB Output is correct
3 Correct 142 ms 1608 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 5 ms 212 KB Output is correct
6 Correct 33 ms 3664 KB Output is correct
7 Correct 52 ms 8440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 155 ms 18064 KB Output is correct
2 Correct 293 ms 18512 KB Output is correct
3 Correct 259 ms 17688 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 60 ms 212 KB Output is correct
6 Correct 331 ms 2648 KB Output is correct
7 Correct 471 ms 49540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1069 ms 98872 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 104 ms 12600 KB Output is correct
2 Correct 301 ms 33124 KB Output is correct
3 Correct 23 ms 4308 KB Output is correct
4 Correct 23 ms 4424 KB Output is correct
5 Correct 68 ms 324 KB Output is correct
6 Correct 92 ms 12512 KB Output is correct
7 Execution timed out 1092 ms 115324 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1038 ms 100580 KB Time limit exceeded
2 Halted 0 ms 0 KB -