Submission #461293

# Submission time Handle Problem Language Result Execution time Memory
461293 2021-08-09T16:56:20 Z vanic Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
247 ms 20900 KB
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

const int maxn=45;

vector < ll > v[2];

int n;
ll m;
ll a[maxn];
ll pref[maxn];
ll sol;
int gran, ind;


void rijesi(int x, ll sum){
//	cout << x << endl;
	if(x==gran){
		v[ind].push_back(sum);
		return;
	}
	rijesi(x+1, sum+a[x]);
	rijesi(x+1, sum);
}

int main(){
	scanf("%d%lld", &n, &m);
	for(int i=0; i<n; i++){
		scanf("%lld", a+i);
		pref[i+1]=pref[i]+a[i];
	}
	gran=n/2;
	ind=0;
	rijesi(0, 0);
	gran=n;
	ind=1;
	rijesi(n/2, 0);
	sort(v[0].begin(), v[0].end());
	sort(v[1].begin(), v[1].end());
	int pos=0;
	for(int i=v[0].size()-1; i>=0; i--){
		while(pos<(int)v[1].size() && v[1][pos]<=m-v[0][i]){
			pos++;
		}
		sol+=pos;
	}
	printf("%lld\n", sol);
	return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:34:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |  scanf("%d%lld", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~~~
bobek.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |   scanf("%lld", a+i);
      |   ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 1952 KB Output is correct
2 Correct 64 ms 5404 KB Output is correct
3 Correct 230 ms 20796 KB Output is correct
4 Correct 54 ms 5436 KB Output is correct
5 Correct 8 ms 1496 KB Output is correct
6 Correct 6 ms 844 KB Output is correct
7 Correct 12 ms 1560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 2752 KB Output is correct
2 Correct 19 ms 1864 KB Output is correct
3 Correct 94 ms 10564 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 4 ms 844 KB Output is correct
6 Correct 12 ms 1476 KB Output is correct
7 Correct 12 ms 1476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 3524 KB Output is correct
2 Correct 80 ms 6608 KB Output is correct
3 Correct 84 ms 6592 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 41 ms 6560 KB Output is correct
6 Correct 182 ms 20720 KB Output is correct
7 Correct 79 ms 6716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 168 ms 12732 KB Output is correct
2 Correct 19 ms 1948 KB Output is correct
3 Correct 6 ms 844 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 4 ms 844 KB Output is correct
6 Correct 166 ms 12664 KB Output is correct
7 Correct 13 ms 1476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 1864 KB Output is correct
2 Correct 53 ms 5436 KB Output is correct
3 Correct 6 ms 960 KB Output is correct
4 Correct 6 ms 960 KB Output is correct
5 Correct 44 ms 6592 KB Output is correct
6 Correct 19 ms 1864 KB Output is correct
7 Correct 231 ms 20760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 226 ms 20800 KB Output is correct
2 Correct 19 ms 1864 KB Output is correct
3 Correct 6 ms 844 KB Output is correct
4 Correct 247 ms 20900 KB Output is correct
5 Correct 60 ms 10580 KB Output is correct
6 Correct 13 ms 1476 KB Output is correct
7 Correct 25 ms 2752 KB Output is correct