Submission #118660

# Submission time Handle Problem Language Result Execution time Memory
118660 2019-06-19T10:37:07 Z roseanne_pcy Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
507 ms 8676 KB
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

int n;
ll S;

const int maxn = 45;
ll arr[maxn];

vector< ll > half;

ll ways;

int main()
{
	scanf("%d %lld", &n, &S);
	for(int i = 1; i<= n; i++) scanf("%lld", &arr[i]);
	int m = n/2;
	for(int bit = 0; bit< (1<<m); bit++)
	{
		ll loc = 0;
		for(int i = 0; i< m; i++)
		{
			if((1<<i) & bit) loc += arr[i+1];
		}
		half.pb(loc);
	}
	sort(half.begin(), half.end());
	m = n-n/2;
	for(int bit = 0; bit< (1<<m); bit++)
	{
		ll loc = 0;
		for(int i = 0; i< m; i++)
		{
			if((1<<i)&bit) loc += arr[n/2+1+i];
		}
		ways += upper_bound(half.begin(), half.end(), S-loc)-half.begin();
	}
	printf("%lld\n", ways);
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %lld", &n, &S);
  ~~~~~^~~~~~~~~~~~~~~~~~~
bobek.cpp:24:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 1; i<= n; i++) scanf("%lld", &arr[i]);
                             ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 1020 KB Output is correct
2 Correct 106 ms 2548 KB Output is correct
3 Correct 507 ms 8672 KB Output is correct
4 Correct 103 ms 2548 KB Output is correct
5 Correct 18 ms 1020 KB Output is correct
6 Correct 9 ms 640 KB Output is correct
7 Correct 16 ms 1148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 1528 KB Output is correct
2 Correct 34 ms 1020 KB Output is correct
3 Correct 210 ms 4584 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 8 ms 768 KB Output is correct
6 Correct 17 ms 1020 KB Output is correct
7 Correct 15 ms 1020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 1528 KB Output is correct
2 Correct 171 ms 2548 KB Output is correct
3 Correct 165 ms 2548 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 99 ms 2572 KB Output is correct
6 Correct 254 ms 8668 KB Output is correct
7 Correct 77 ms 2548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 344 ms 4508 KB Output is correct
2 Correct 27 ms 1020 KB Output is correct
3 Correct 11 ms 640 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 9 ms 640 KB Output is correct
6 Correct 195 ms 4584 KB Output is correct
7 Correct 16 ms 1024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 1020 KB Output is correct
2 Correct 99 ms 2548 KB Output is correct
3 Correct 10 ms 640 KB Output is correct
4 Correct 10 ms 768 KB Output is correct
5 Correct 115 ms 2548 KB Output is correct
6 Correct 23 ms 1020 KB Output is correct
7 Correct 252 ms 8672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 410 ms 8668 KB Output is correct
2 Correct 34 ms 1020 KB Output is correct
3 Correct 10 ms 768 KB Output is correct
4 Correct 495 ms 8676 KB Output is correct
5 Correct 130 ms 4580 KB Output is correct
6 Correct 16 ms 892 KB Output is correct
7 Correct 28 ms 1528 KB Output is correct