Submission #24702

# Submission time Handle Problem Language Result Execution time Memory
24702 2017-06-12T01:49:50 Z kdh9949 Ice Hockey World Championship (CEOI15_bobek) C++14
90 / 100
366 ms 18404 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int n, p, q;
ll m, x[20], y[20], a[1048576], b[1048576], ans;

int main(){
	scanf("%d%lld", &n, &m);
	p = n / 2; q = n - p;
	if(n == 1){
		ll x; scanf("%lld", &x);
		printf("%lld\n", x <= m ? x : 0);
		return 0;
	}
	for(int i = 0; i < p; i++){
		scanf("%lld", x + i);
	}
	for(int i = 0; i < q; i++){
		scanf("%lld", y + i);
	}
	for(int i = 0; i < (1 << p); i++){
		for(int j = 0; j < p; j++) if((1 << j) & i) a[i] += x[j];
	}
	for(int i = 0; i < (1 << q); i++){
		for(int j = 0; j < q; j++) if((1 << j) & i) b[i] += y[j];
	}
	sort(a, a + (1 << p));
	sort(b, b + (1 << q));
	for(int i = 0, j = (1 << q) - 1; i < (1 << p); i++){
		for(; j >= 0; j--){
			if(a[i] + b[j] <= m) break;
		}
		ans += (j + 1);
	}
	printf("%lld\n", ans);
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:9:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%lld", &n, &m);
                         ^
bobek.cpp:12:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   ll x; scanf("%lld", &x);
                          ^
bobek.cpp:17:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", x + i);
                       ^
bobek.cpp:20:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", y + i);
                       ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 18404 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 18404 KB Output is correct
2 Correct 0 ms 18404 KB Output is correct
3 Correct 0 ms 18404 KB Output is correct
4 Correct 0 ms 18404 KB Output is correct
5 Correct 0 ms 18404 KB Output is correct
6 Correct 0 ms 18404 KB Output is correct
7 Correct 0 ms 18404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 18404 KB Output is correct
2 Correct 0 ms 18404 KB Output is correct
3 Correct 0 ms 18404 KB Output is correct
4 Correct 0 ms 18404 KB Output is correct
5 Correct 0 ms 18404 KB Output is correct
6 Correct 0 ms 18404 KB Output is correct
7 Correct 0 ms 18404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 18404 KB Output is correct
2 Correct 0 ms 18404 KB Output is correct
3 Correct 0 ms 18404 KB Output is correct
4 Correct 0 ms 18404 KB Output is correct
5 Correct 0 ms 18404 KB Output is correct
6 Correct 0 ms 18404 KB Output is correct
7 Correct 0 ms 18404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 18404 KB Output is correct
2 Correct 86 ms 18404 KB Output is correct
3 Correct 366 ms 18404 KB Output is correct
4 Correct 83 ms 18404 KB Output is correct
5 Correct 13 ms 18404 KB Output is correct
6 Correct 6 ms 18404 KB Output is correct
7 Correct 16 ms 18404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 18404 KB Output is correct
2 Correct 29 ms 18404 KB Output is correct
3 Correct 146 ms 18404 KB Output is correct
4 Correct 0 ms 18404 KB Output is correct
5 Correct 3 ms 18404 KB Output is correct
6 Correct 19 ms 18404 KB Output is correct
7 Correct 19 ms 18404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 59 ms 18404 KB Output is correct
2 Correct 126 ms 18404 KB Output is correct
3 Correct 129 ms 18404 KB Output is correct
4 Correct 0 ms 18404 KB Output is correct
5 Correct 79 ms 18404 KB Output is correct
6 Correct 313 ms 18404 KB Output is correct
7 Correct 129 ms 18404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 256 ms 18404 KB Output is correct
2 Correct 29 ms 18404 KB Output is correct
3 Correct 9 ms 18404 KB Output is correct
4 Correct 0 ms 18404 KB Output is correct
5 Correct 6 ms 18404 KB Output is correct
6 Correct 276 ms 18404 KB Output is correct
7 Correct 19 ms 18404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 18404 KB Output is correct
2 Correct 86 ms 18404 KB Output is correct
3 Correct 9 ms 18404 KB Output is correct
4 Correct 9 ms 18404 KB Output is correct
5 Correct 83 ms 18404 KB Output is correct
6 Correct 29 ms 18404 KB Output is correct
7 Correct 349 ms 18404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 349 ms 18404 KB Output is correct
2 Correct 29 ms 18404 KB Output is correct
3 Correct 9 ms 18404 KB Output is correct
4 Correct 349 ms 18404 KB Output is correct
5 Correct 109 ms 18404 KB Output is correct
6 Correct 19 ms 18404 KB Output is correct
7 Correct 43 ms 18404 KB Output is correct