Submission #39419

# Submission time Handle Problem Language Result Execution time Memory
39419 2018-01-14T18:44:23 Z farmersrice Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
256 ms 26792 KB
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
//#pragma GCC target ("avx,tune=native")
//Use above if bruteforcing with lots of small operations. Or just use it anytime, there's no downside. AVX is better slightly
/*
TASK: hidden
LANG: C++11
*/
using namespace std;
typedef long long ll;
typedef pair<int, int> pair2;
typedef pair<int, pair<int, int> > pair3;
typedef pair<int, pair<int, pair<int, int> > > pair4;
#define MAXN 43
#define INF 1000000000000000000LL
#define mp make_pair
#define add push_back
#define remove pop

int n;
ll values[MAXN];
int size1, size2;

ll m;
vector<ll> one;
vector<ll> two;

void dfs(int depth, ll sum, int bound, vector<ll> &target) {
	if (depth == bound) {
		target.add(sum);
		return;
	}
	dfs(depth + 1, sum + values[depth], bound, target);
	dfs(depth + 1, sum, bound, target);
}

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

	cin >> n >> m;

	for (int i = 0; i < n; i++) {
		cin >> values[i];
	}

	dfs(0, 0, n / 2, one);
	dfs(n / 2, 0, n, two);

	sort(one.begin(), one.end());
	sort(two.begin(), two.end());

	//assert(one.size() + two.size() < 5000000);

	ll answer = 0;
	int twopointer = two.size() - 1;
	for (int i = 0; i < (int) (one.size()); i++) {
		if (one[i] > m) break;
		while (twopointer >= 0 && two[twopointer] > m - one[i]) {
			twopointer--;
		}
		answer += twopointer + 1;
	}

	cout << answer << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2176 KB Output is correct
2 Correct 0 ms 2176 KB Output is correct
3 Correct 0 ms 2176 KB Output is correct
4 Correct 0 ms 2176 KB Output is correct
5 Correct 0 ms 2176 KB Output is correct
6 Correct 0 ms 2176 KB Output is correct
7 Correct 0 ms 2176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2176 KB Output is correct
2 Correct 0 ms 2176 KB Output is correct
3 Correct 0 ms 2176 KB Output is correct
4 Correct 0 ms 2176 KB Output is correct
5 Correct 0 ms 2176 KB Output is correct
6 Correct 0 ms 2176 KB Output is correct
7 Correct 0 ms 2176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2176 KB Output is correct
2 Correct 0 ms 2176 KB Output is correct
3 Correct 0 ms 2176 KB Output is correct
4 Correct 0 ms 2176 KB Output is correct
5 Correct 0 ms 2176 KB Output is correct
6 Correct 0 ms 2176 KB Output is correct
7 Correct 0 ms 2176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 4268 KB Output is correct
2 Correct 56 ms 8360 KB Output is correct
3 Correct 236 ms 26792 KB Output is correct
4 Correct 59 ms 8360 KB Output is correct
5 Correct 6 ms 3752 KB Output is correct
6 Correct 6 ms 2860 KB Output is correct
7 Correct 9 ms 3752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 5288 KB Output is correct
2 Correct 16 ms 4268 KB Output is correct
3 Correct 89 ms 14504 KB Output is correct
4 Correct 0 ms 2176 KB Output is correct
5 Correct 0 ms 2860 KB Output is correct
6 Correct 13 ms 3752 KB Output is correct
7 Correct 9 ms 3752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 6316 KB Output is correct
2 Correct 89 ms 10412 KB Output is correct
3 Correct 83 ms 10412 KB Output is correct
4 Correct 0 ms 2176 KB Output is correct
5 Correct 43 ms 10412 KB Output is correct
6 Correct 189 ms 26792 KB Output is correct
7 Correct 89 ms 10412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 183 ms 18604 KB Output is correct
2 Correct 19 ms 4268 KB Output is correct
3 Correct 6 ms 2860 KB Output is correct
4 Correct 0 ms 2176 KB Output is correct
5 Correct 3 ms 2860 KB Output is correct
6 Correct 173 ms 18604 KB Output is correct
7 Correct 9 ms 3752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 4268 KB Output is correct
2 Correct 56 ms 8360 KB Output is correct
3 Correct 6 ms 2860 KB Output is correct
4 Correct 6 ms 2860 KB Output is correct
5 Correct 43 ms 10412 KB Output is correct
6 Correct 16 ms 4268 KB Output is correct
7 Correct 233 ms 26792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 243 ms 26792 KB Output is correct
2 Correct 19 ms 4268 KB Output is correct
3 Correct 6 ms 2860 KB Output is correct
4 Correct 256 ms 26792 KB Output is correct
5 Correct 59 ms 14504 KB Output is correct
6 Correct 9 ms 3752 KB Output is correct
7 Correct 26 ms 5288 KB Output is correct