Submission #879432

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

int main() {
	int N;
	ll K;
	scanf("%d %lld", &N, &K);
	vector<int> arr(N);
	for(int i=0;i<N;i++) {
		scanf("%d", &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 += 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("%d", &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 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 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 29 ms 1880 KB Output is correct
2 Correct 88 ms 5348 KB Output is correct
3 Correct 417 ms 21664 KB Output is correct
4 Correct 89 ms 5380 KB Output is correct
5 Correct 12 ms 1492 KB Output is correct
6 Correct 6 ms 984 KB Output is correct
7 Correct 14 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 2768 KB Output is correct
2 Correct 28 ms 1880 KB Output is correct
3 Correct 176 ms 10936 KB Output is correct
4 Correct 0 ms 436 KB Output is correct
5 Correct 6 ms 984 KB Output is correct
6 Correct 13 ms 1492 KB Output is correct
7 Correct 12 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 3668 KB Output is correct
2 Correct 133 ms 8260 KB Output is correct
3 Correct 131 ms 7500 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 72 ms 7492 KB Output is correct
6 Correct 248 ms 21524 KB Output is correct
7 Correct 88 ms 8268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 187 ms 13628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 1880 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 243 ms 21072 KB Output isn't correct
2 Halted 0 ms 0 KB -