Submission #39404

# Submission time Handle Problem Language Result Execution time Memory
39404 2018-01-14T18:17:55 Z farmersrice Ice Hockey World Championship (CEOI15_bobek) C++14
0 / 100
113 ms 9392 KB
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#pragma GCC target ("avx,tune=native")
//Use above if bruteforcing with lots of small operations. Or just use it anytime, there's no downside. AVX is better slightly
/*
TASK: hidden
LANG: C++11
*/
using namespace std;
typedef long long ll;
typedef pair<int, int> pair2;
typedef pair<int, pair<int, int> > pair3;
typedef pair<int, pair<int, pair<int, int> > > pair4;
#define MAXN 23
#define INF 1000000000000000000LL
#define mp make_pair
#define add push_back
#define remove pop

int n;
ll values[MAXN];
ll set1[MAXN];
ll set2[MAXN];
int size1, size2;

ll m;
vector<ll> one;
vector<ll> two;

int main() {
	if (fopen("FILENAME.in", "r")) {
		freopen("FILENAME.in", "r", stdin);
		freopen("FILENAME.out", "w", stdout);
	}
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);

	cin >> n >> m;

	for (int i = 0; i < n; i++) {
		cin >> values[i];

		if (values[i] % 2 == 0) {
			set1[size1++] = values[i];
		} else {
			set2[size2++] = values[i];
		}
	}	

	sort(set1, set1 + size1);
	sort(set2, set2 + size2);

	for (int i = 0; i < (1 << size1); i++) {
		ll sum = 0;
		for (int j = 0; j < size1; j++) {
			if (i & (1 << j)) {
				sum += set1[j];
			}
		}
		one.add(sum);
	}

	for (int i = 0; i < (1 << size2); i++) {
		ll sum = 0;
		for (int j = 0; j < size2; j++) {
			if (i & (1 << j)) {
				sum += set2[j];
			}
		}
		two.add(sum);
	}

	sort(one.rbegin(), one.rend());
	sort(two.begin(), two.end());

	ll answer = 0;
	ll twopointer = 0;
	for (int i = 0; i < one.size(); i++) {
		while (one[i] + two[twopointer] <= m) {
			twopointer++;
		}
		answer += twopointer;
	}

	cout << answer << endl;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:79:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < one.size(); i++) {
                    ^
bobek.cpp:33:37: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen("FILENAME.in", "r", stdin);
                                     ^
bobek.cpp:34:39: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen("FILENAME.out", "w", stdout);
                                       ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2180 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2180 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2180 KB Output is correct
2 Correct 0 ms 2180 KB Output is correct
3 Correct 0 ms 2180 KB Output is correct
4 Incorrect 0 ms 2180 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 13 ms 2988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 3756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 3756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2180 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 2600 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 113 ms 9392 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2356 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -