Submission #204468

# Submission time Handle Problem Language Result Execution time Memory
204468 2020-02-25T20:57:48 Z staniewzki Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
569 ms 8788 KB
#include<bits/stdc++.h>
using namespace std;
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}
 
#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }
 
using LL = long long;
using PII = pair<int, int>;

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

	int n;
	LL m;
	cin >> n >> m;
	vector<LL> a(n);
	REP(i, n) cin >> a[i];

	vector<LL> left;
	REP(i, (1 << (n / 2))) {
		LL sum = 0;
		REP(j, n / 2) {
			if(i & (1 << j))
				sum += a[j];
		}
		left.emplace_back(sum);
	}
	sort(left.begin(), left.end());

	LL ans = 0;
	REP(i, (1 << ((n + 1) / 2))) {
		LL sum = 0;
		FOR(j, n / 2, n - 1) {
			if(i & (1 << (j - n / 2))) 
				sum += a[j];
		}
		auto it = upper_bound(left.begin(), left.end(), m - sum);
		ans += distance(left.begin(), it);
	}

	cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 248 KB Output is correct
4 Correct 5 ms 380 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 248 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 380 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 380 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 1016 KB Output is correct
2 Correct 116 ms 2544 KB Output is correct
3 Correct 569 ms 8720 KB Output is correct
4 Correct 114 ms 2544 KB Output is correct
5 Correct 23 ms 1016 KB Output is correct
6 Correct 12 ms 760 KB Output is correct
7 Correct 20 ms 1016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 1520 KB Output is correct
2 Correct 41 ms 1016 KB Output is correct
3 Correct 212 ms 4584 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 12 ms 760 KB Output is correct
6 Correct 20 ms 1016 KB Output is correct
7 Correct 20 ms 1016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 85 ms 1528 KB Output is correct
2 Correct 181 ms 2544 KB Output is correct
3 Correct 173 ms 2544 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 99 ms 2540 KB Output is correct
6 Correct 271 ms 8676 KB Output is correct
7 Correct 90 ms 2536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 375 ms 4584 KB Output is correct
2 Correct 37 ms 1016 KB Output is correct
3 Correct 16 ms 760 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 13 ms 760 KB Output is correct
6 Correct 201 ms 4588 KB Output is correct
7 Correct 20 ms 1016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 1016 KB Output is correct
2 Correct 113 ms 2544 KB Output is correct
3 Correct 14 ms 760 KB Output is correct
4 Correct 15 ms 760 KB Output is correct
5 Correct 122 ms 2540 KB Output is correct
6 Correct 25 ms 1016 KB Output is correct
7 Correct 278 ms 8788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 431 ms 8672 KB Output is correct
2 Correct 41 ms 1016 KB Output is correct
3 Correct 15 ms 760 KB Output is correct
4 Correct 554 ms 8672 KB Output is correct
5 Correct 149 ms 4588 KB Output is correct
6 Correct 20 ms 1016 KB Output is correct
7 Correct 36 ms 1524 KB Output is correct