Submission #24705

# Submission time Handle Problem Language Result Execution time Memory
24705 2017-06-12T01:50:51 Z kdh9949 Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
369 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 ? 2 : 1);
		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:13:34: warning: format '%lld' expects argument of type 'long long int', but argument 2 has type 'int' [-Wformat=]
   printf("%lld\n", x <= m ? 2 : 1);
                                  ^
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 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 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 26 ms 18404 KB Output is correct
2 Correct 79 ms 18404 KB Output is correct
3 Correct 369 ms 18404 KB Output is correct
4 Correct 79 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 19 ms 18404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 18404 KB Output is correct
2 Correct 26 ms 18404 KB Output is correct
3 Correct 143 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 19 ms 18404 KB Output is correct
7 Correct 16 ms 18404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 18404 KB Output is correct
2 Correct 126 ms 18404 KB Output is correct
3 Correct 126 ms 18404 KB Output is correct
4 Correct 0 ms 18404 KB Output is correct
5 Correct 86 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 266 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 26 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 89 ms 18404 KB Output is correct
6 Correct 29 ms 18404 KB Output is correct
7 Correct 346 ms 18404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 353 ms 18404 KB Output is correct
2 Correct 26 ms 18404 KB Output is correct
3 Correct 9 ms 18404 KB Output is correct
4 Correct 363 ms 18404 KB Output is correct
5 Correct 129 ms 18404 KB Output is correct
6 Correct 19 ms 18404 KB Output is correct
7 Correct 36 ms 18404 KB Output is correct