답안 #37366

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
37366 2017-12-24T16:57:34 Z cheater2k Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
253 ms 26792 KB
#include <bits/stdc++.h>
using namespace std;

int n;
long long M;
long long a[44];
long long ans;
vector< long long > v1, v2;

void bt(int pos, int lim, long long sum, vector<long long> &v) {
	if (pos == lim) {
		v.push_back(sum); return;
	}
	bt(pos + 1, lim, sum, v);
	bt(pos + 1, lim, sum + a[pos], v);
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> M;
	for (int i = 0; i < n; ++i) cin >> a[i];
	bt(0, n / 2, 0, v1);
	bt(n / 2, n, 0, v2);

	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());

	int ptr = v2.size() - 1;
	for (int i = 0; i < v1.size(); ++i) {
		if (v1[i] > M) break;
		while(ptr >= 0 && v2[ptr] > M - v1[i]) --ptr;
		// [0...ptr]
		ans += ptr + 1;
	}

	printf("%lld\n", ans);
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:29:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < v1.size(); ++i) {
                    ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2176 KB Output is correct
2 Correct 0 ms 2176 KB Output is correct
3 Correct 0 ms 2176 KB Output is correct
4 Correct 0 ms 2176 KB Output is correct
5 Correct 0 ms 2176 KB Output is correct
6 Correct 0 ms 2176 KB Output is correct
7 Correct 0 ms 2176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2176 KB Output is correct
2 Correct 0 ms 2176 KB Output is correct
3 Correct 0 ms 2176 KB Output is correct
4 Correct 0 ms 2176 KB Output is correct
5 Correct 0 ms 2176 KB Output is correct
6 Correct 0 ms 2176 KB Output is correct
7 Correct 0 ms 2176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2176 KB Output is correct
2 Correct 0 ms 2176 KB Output is correct
3 Correct 0 ms 2176 KB Output is correct
4 Correct 0 ms 2176 KB Output is correct
5 Correct 0 ms 2176 KB Output is correct
6 Correct 0 ms 2176 KB Output is correct
7 Correct 0 ms 2176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 4268 KB Output is correct
2 Correct 63 ms 8360 KB Output is correct
3 Correct 253 ms 26792 KB Output is correct
4 Correct 69 ms 8360 KB Output is correct
5 Correct 9 ms 3752 KB Output is correct
6 Correct 3 ms 2860 KB Output is correct
7 Correct 9 ms 3752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 5288 KB Output is correct
2 Correct 19 ms 4268 KB Output is correct
3 Correct 93 ms 14504 KB Output is correct
4 Correct 0 ms 2176 KB Output is correct
5 Correct 3 ms 2860 KB Output is correct
6 Correct 13 ms 3752 KB Output is correct
7 Correct 13 ms 3752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 6316 KB Output is correct
2 Correct 89 ms 10412 KB Output is correct
3 Correct 83 ms 10412 KB Output is correct
4 Correct 0 ms 2176 KB Output is correct
5 Correct 36 ms 10412 KB Output is correct
6 Correct 189 ms 26792 KB Output is correct
7 Correct 86 ms 10412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 176 ms 18604 KB Output is correct
2 Correct 19 ms 4268 KB Output is correct
3 Correct 6 ms 2860 KB Output is correct
4 Correct 0 ms 2176 KB Output is correct
5 Correct 3 ms 2860 KB Output is correct
6 Correct 179 ms 18604 KB Output is correct
7 Correct 13 ms 3752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 4268 KB Output is correct
2 Correct 56 ms 8360 KB Output is correct
3 Correct 6 ms 2860 KB Output is correct
4 Correct 6 ms 2860 KB Output is correct
5 Correct 59 ms 10412 KB Output is correct
6 Correct 16 ms 4268 KB Output is correct
7 Correct 249 ms 26792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 249 ms 26792 KB Output is correct
2 Correct 19 ms 4268 KB Output is correct
3 Correct 6 ms 2860 KB Output is correct
4 Correct 249 ms 26792 KB Output is correct
5 Correct 59 ms 14504 KB Output is correct
6 Correct 9 ms 3752 KB Output is correct
7 Correct 23 ms 5288 KB Output is correct