Submission #899499

# Submission time Handle Problem Language Result Execution time Memory
899499 2024-01-06T10:12:20 Z MongHwa Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
214 ms 22732 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define ll long long

ll val;
vector<ll> v1, v2;
vector<ll> target1, target2;

void go(int k, vector<ll>& v, vector<ll>& t, int d)
{
	if(k == d)
	{
		if(val > 0)
			t.push_back(val);
		return;
	}

	val += v[k];
	go(k+1, v, t, d);
	val -= v[k];
	go(k+1, v, t, d);
}

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

	int n; ll m;
	cin >> n >> m;

	for(int i = 0; i < n; i++)
	{
		ll x;
		cin >> x;

		if(i < n/2)
			v1.push_back(x);
		else
			v2.push_back(x);
	}

	int d1 = v1.size(), d2 = v2.size();
	go(0, v1, target1, d1);
	go(0, v2, target2, d2);

	sort(target1.begin(), target1.end());
	sort(target2.begin(), target2.end());

	ll ans = 0;
	ans += (upper_bound(target1.begin(), target1.end(), m) - target1.begin());
	ans += (upper_bound(target2.begin(), target2.end(), m) - target2.begin());

	for(int i = 0; i < (int)target1.size(); i++)
		ans += (upper_bound(target2.begin(), target2.end(), m-target1[i]) - target2.begin());
	ans++;

	cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 600 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 2144 KB Output is correct
2 Correct 49 ms 5492 KB Output is correct
3 Correct 205 ms 21704 KB Output is correct
4 Correct 49 ms 5588 KB Output is correct
5 Correct 9 ms 1756 KB Output is correct
6 Correct 5 ms 1096 KB Output is correct
7 Correct 10 ms 1756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 3032 KB Output is correct
2 Correct 16 ms 2144 KB Output is correct
3 Correct 73 ms 11984 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 3 ms 1116 KB Output is correct
6 Correct 10 ms 1756 KB Output is correct
7 Correct 10 ms 1640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 3676 KB Output is correct
2 Correct 78 ms 6744 KB Output is correct
3 Correct 71 ms 7764 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 34 ms 8564 KB Output is correct
6 Correct 156 ms 22732 KB Output is correct
7 Correct 62 ms 6900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 144 ms 14164 KB Output is correct
2 Correct 16 ms 2144 KB Output is correct
3 Correct 6 ms 1116 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 3 ms 1116 KB Output is correct
6 Correct 135 ms 13140 KB Output is correct
7 Correct 12 ms 1888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 2144 KB Output is correct
2 Correct 48 ms 5588 KB Output is correct
3 Correct 5 ms 1112 KB Output is correct
4 Correct 5 ms 1116 KB Output is correct
5 Correct 35 ms 7512 KB Output is correct
6 Correct 14 ms 2140 KB Output is correct
7 Correct 187 ms 22472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 196 ms 22476 KB Output is correct
2 Correct 19 ms 2140 KB Output is correct
3 Correct 6 ms 1112 KB Output is correct
4 Correct 214 ms 22216 KB Output is correct
5 Correct 48 ms 11980 KB Output is correct
6 Correct 10 ms 1756 KB Output is correct
7 Correct 20 ms 2876 KB Output is correct