Submission #462017

# Submission time Handle Problem Language Result Execution time Memory
462017 2021-08-10T07:07:43 Z kingfran1907 Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
516 ms 8700 KB
#include <bits/stdc++.h>
#define X first
#define Y second

using namespace std;
typedef long long llint;

const int maxn = 2e5+10;
const int base = 31337;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int logo = 18;
const int off = 1 << logo;
const int treesiz = off << 1;

int n;
llint m;
llint niz[maxn];
vector< llint > v;

int main() {
	scanf("%d%lld", &n, &m);
	for (int i = 0; i < n; i++)
		scanf("%lld", niz+i);
		
	int hf = n / 2;
	int lim = (1 << hf);
	for (int mask = 0; mask < lim; mask++) {
		llint sum = 0;
		for (int i = 0; i < hf; i++)
			if (mask & (1 << i)) sum += niz[i];	
		v.push_back(sum);
	}
	sort(v.begin(), v.end());
	
	llint sol = 0;
	lim = (1 << (n - hf));
	for (int mask = 0; mask < lim; mask++) {
		llint sum = 0;
		for (int i = 0; i < n - hf; i++) {
			if (mask & (1 << i)) sum += niz[i + n / 2];
		}
		
		int ind = upper_bound(v.begin(), v.end(), m - sum) - v.begin();
		sol += ind;
	}
	printf("%lld\n", sol);
	return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  scanf("%d%lld", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~~~
bobek.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |   scanf("%lld", niz+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 296 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 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 0 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 296 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 32 ms 840 KB Output is correct
2 Correct 109 ms 2496 KB Output is correct
3 Correct 515 ms 8620 KB Output is correct
4 Correct 107 ms 2496 KB Output is correct
5 Correct 17 ms 904 KB Output is correct
6 Correct 8 ms 588 KB Output is correct
7 Correct 15 ms 840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 1364 KB Output is correct
2 Correct 35 ms 840 KB Output is correct
3 Correct 206 ms 4520 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 8 ms 588 KB Output is correct
6 Correct 15 ms 872 KB Output is correct
7 Correct 16 ms 836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 74 ms 1428 KB Output is correct
2 Correct 168 ms 2420 KB Output is correct
3 Correct 168 ms 2496 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 96 ms 2508 KB Output is correct
6 Correct 252 ms 8612 KB Output is correct
7 Correct 92 ms 2496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 352 ms 4540 KB Output is correct
2 Correct 30 ms 840 KB Output is correct
3 Correct 12 ms 588 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 8 ms 588 KB Output is correct
6 Correct 184 ms 4484 KB Output is correct
7 Correct 15 ms 840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 840 KB Output is correct
2 Correct 100 ms 2496 KB Output is correct
3 Correct 9 ms 588 KB Output is correct
4 Correct 11 ms 588 KB Output is correct
5 Correct 118 ms 2496 KB Output is correct
6 Correct 21 ms 840 KB Output is correct
7 Correct 271 ms 8700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 407 ms 8596 KB Output is correct
2 Correct 36 ms 840 KB Output is correct
3 Correct 11 ms 588 KB Output is correct
4 Correct 516 ms 8580 KB Output is correct
5 Correct 139 ms 4492 KB Output is correct
6 Correct 15 ms 840 KB Output is correct
7 Correct 29 ms 1396 KB Output is correct