Submission #281998

# Submission time Handle Problem Language Result Execution time Memory
281998 2020-08-23T18:52:03 Z ChrisT Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
253 ms 20944 KB
#include <bits/stdc++.h>
using namespace std;
int main () {
	int n; long long m;
	scanf ("%d %lld",&n,&m);
	vector<long long> a(n), sums1, sums2; int ed;
	for (auto &au : a) scanf ("%lld",&au);
	function<void(int,long long,vector<long long>&)> gen = [&] (int ind, long long sum, vector<long long> &sums) {
		if (ind == ed) return (void)sums.push_back(sum);
		gen(ind+1,sum,sums); gen(ind+1,sum+a[ind],sums);
	};
	ed = n/2;
	gen(0,0,sums1);
	ed = n;
	gen(n/2,0,sums2);
	sort(sums1.begin(),sums1.end()); sort(sums2.begin(),sums2.end());
	long long ret = 0; int pp = (int)sums2.size() - 1;
	for (int i = 0; i < (int)sums1.size(); i++) {
		while (~pp && sums1[i] + sums2[pp] > m) --pp;
		ret += pp + 1;
	}
	printf ("%lld\n",ret);
	return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:5:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    5 |  scanf ("%d %lld",&n,&m);
      |  ~~~~~~^~~~~~~~~~~~~~~~~
bobek.cpp:7:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |  for (auto &au : a) scanf ("%lld",&au);
      |                     ~~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 2040 KB Output is correct
2 Correct 67 ms 5488 KB Output is correct
3 Correct 249 ms 20828 KB Output is correct
4 Correct 58 ms 5488 KB Output is correct
5 Correct 9 ms 1656 KB Output is correct
6 Correct 7 ms 1020 KB Output is correct
7 Correct 15 ms 1656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 2932 KB Output is correct
2 Correct 22 ms 2040 KB Output is correct
3 Correct 101 ms 10604 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 4 ms 1020 KB Output is correct
6 Correct 13 ms 1656 KB Output is correct
7 Correct 13 ms 1656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 3572 KB Output is correct
2 Correct 88 ms 6640 KB Output is correct
3 Correct 88 ms 6640 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 45 ms 6640 KB Output is correct
6 Correct 198 ms 20816 KB Output is correct
7 Correct 87 ms 6640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 183 ms 12772 KB Output is correct
2 Correct 21 ms 2040 KB Output is correct
3 Correct 7 ms 1020 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 5 ms 1020 KB Output is correct
6 Correct 179 ms 12780 KB Output is correct
7 Correct 13 ms 1656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 2040 KB Output is correct
2 Correct 59 ms 5520 KB Output is correct
3 Correct 7 ms 1020 KB Output is correct
4 Correct 7 ms 1020 KB Output is correct
5 Correct 55 ms 6640 KB Output is correct
6 Correct 20 ms 2040 KB Output is correct
7 Correct 244 ms 20816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 253 ms 20944 KB Output is correct
2 Correct 21 ms 2040 KB Output is correct
3 Correct 7 ms 1020 KB Output is correct
4 Correct 252 ms 20820 KB Output is correct
5 Correct 74 ms 10604 KB Output is correct
6 Correct 13 ms 1656 KB Output is correct
7 Correct 28 ms 2932 KB Output is correct