Submission #879433

# Submission time Handle Problem Language Result Execution time Memory
879433 2023-11-27T11:24:14 Z KN200711 Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
421 ms 22192 KB
# include <bits/stdc++.h>
# define ll long long
using namespace std;

int main() {
	int N;
	ll K;
	scanf("%d %lld", &N, &K);
	vector<ll> arr(N);
	for(int i=0;i<N;i++) {
		scanf("%lld", &arr[i]);
	}
	vector<ll> A, B;
	A.clear();
	B.clear();
	int G = N / 2;
	for(int i=0;i<(1 << G);i++) {
		ll as = 0ll;
		for(int k=0;k<G;k++) {
			if(i&(1 << k)) as += arr[k];
		}
		A.push_back(as);
	}
	for(int i=0;i<(1 << (N - G));i++) {
		ll as = 0ll;
		for(int k=0;k<(N - G);k++) {
			if(i&(1 << k)) as += arr[k + G];
		}
		B.push_back(as);
	}
	sort(B.begin(), B.end());
	ll ans = 0ll;
	for(int i=0;i<A.size();i++) {
		ans += 1ll * ( upper_bound(B.begin(), B.end(), K - A[i]) - B.begin());
	}
	printf("%lld\n", ans);
	return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:33:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  for(int i=0;i<A.size();i++) {
      |              ~^~~~~~~~~
bobek.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  scanf("%d %lld", &N, &K);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~
bobek.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   scanf("%lld", &arr[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~
# 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 0 ms 344 KB Output is correct
4 Correct 0 ms 344 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 0 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 1 ms 348 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 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 26 ms 1880 KB Output is correct
2 Correct 87 ms 5576 KB Output is correct
3 Correct 421 ms 21616 KB Output is correct
4 Correct 87 ms 5312 KB Output is correct
5 Correct 15 ms 1492 KB Output is correct
6 Correct 7 ms 996 KB Output is correct
7 Correct 13 ms 1488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 2768 KB Output is correct
2 Correct 27 ms 1880 KB Output is correct
3 Correct 171 ms 11196 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 6 ms 984 KB Output is correct
6 Correct 13 ms 1488 KB Output is correct
7 Correct 12 ms 1652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 3412 KB Output is correct
2 Correct 126 ms 6984 KB Output is correct
3 Correct 139 ms 6984 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 71 ms 7760 KB Output is correct
6 Correct 229 ms 21916 KB Output is correct
7 Correct 90 ms 8260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 273 ms 14080 KB Output is correct
2 Correct 29 ms 1880 KB Output is correct
3 Correct 9 ms 984 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 6 ms 1108 KB Output is correct
6 Correct 187 ms 13748 KB Output is correct
7 Correct 12 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 1876 KB Output is correct
2 Correct 84 ms 5316 KB Output is correct
3 Correct 9 ms 984 KB Output is correct
4 Correct 8 ms 984 KB Output is correct
5 Correct 85 ms 7968 KB Output is correct
6 Correct 21 ms 1880 KB Output is correct
7 Correct 236 ms 21828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 340 ms 22192 KB Output is correct
2 Correct 28 ms 1880 KB Output is correct
3 Correct 10 ms 984 KB Output is correct
4 Correct 401 ms 21524 KB Output is correct
5 Correct 101 ms 11704 KB Output is correct
6 Correct 13 ms 1620 KB Output is correct
7 Correct 26 ms 2768 KB Output is correct