Submission #748649

# Submission time Handle Problem Language Result Execution time Memory
748649 2023-05-26T16:53:42 Z mariowong Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
263 ms 20844 KB
#include <bits/stdc++.h>
 
using namespace std;
 
long long n,m,a[55],ans;
vector <long long> v,v2;
bool vis[55]; 
void ex(int l,int r,long long sum){
	if (l > r){
		if (r == n)
		v2.push_back(sum);
		else
		v.push_back(sum);
	}
	else
	{
		if (sum+a[l] <= m){
			vis[l]=true;
			ex(l+1,r,sum+a[l]);
		}
		vis[l]=false;
		ex(l+1,r,sum);
	}
}
int main(){
	ios::sync_with_stdio(false);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin >> n >> m;
	for (int i=1;i<=n;i++){
		cin >> a[i];
	}
	ex(1,n/2,0); ex(n/2+1,n,0);
	sort(v.begin(),v.end());
	sort(v2.begin(),v2.end());
	for (int i=0;i<v.size();i++){
		ans+=lower_bound(v2.begin(),v2.end(),m-v[i]+1)-v2.begin();
	}
	cout << ans << "\n";
	return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:36:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |  for (int i=0;i<v.size();i++){
      |               ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 0 ms 324 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 324 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 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 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 1 ms 340 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 0 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 2008 KB Output is correct
2 Correct 63 ms 5388 KB Output is correct
3 Correct 245 ms 20728 KB Output is correct
4 Correct 57 ms 5408 KB Output is correct
5 Correct 8 ms 1612 KB Output is correct
6 Correct 6 ms 984 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 2896 KB Output is correct
2 Correct 21 ms 2008 KB Output is correct
3 Correct 94 ms 10568 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 4 ms 968 KB Output is correct
6 Correct 13 ms 1596 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 3536 KB Output is correct
2 Correct 84 ms 6592 KB Output is correct
3 Correct 88 ms 6608 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 40 ms 6608 KB Output is correct
6 Correct 207 ms 20780 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 178 ms 12732 KB Output is correct
2 Correct 20 ms 2008 KB Output is correct
3 Correct 8 ms 984 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 5 ms 984 KB Output is correct
6 Correct 178 ms 12788 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1988 KB Output is correct
2 Correct 60 ms 5452 KB Output is correct
3 Correct 7 ms 984 KB Output is correct
4 Correct 7 ms 984 KB Output is correct
5 Correct 48 ms 6544 KB Output is correct
6 Correct 22 ms 2012 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 246 ms 20844 KB Output is correct
2 Correct 21 ms 1992 KB Output is correct
3 Correct 7 ms 972 KB Output is correct
4 Correct 263 ms 20832 KB Output is correct
5 Correct 97 ms 10520 KB Output is correct
6 Correct 13 ms 1604 KB Output is correct
7 Correct 1 ms 212 KB Output is correct