답안 #97672

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
97672 2019-02-17T17:34:01 Z jasony123123 Ice Hockey World Championship (CEOI15_bobek) C++11
100 / 100
235 ms 20844 KB
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <array>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;

#define FOR(i,start,end) for(int i=start;i<(int)(end);i++)
#define FORE(i,start,end) for(int i=start;i<=(int)end;i++)
#define RFOR(i,start,end) for(int i = start; i>end; i--)
#define RFORE(i,start,end) for(int i = start; i>=end; i--)
#define all(a) a.begin(), a.end()
#define mt make_tuple
#define mp make_pair
#define v vector
#define sf scanf
#define pf printf
#define dvar(x) cout << #x << " := " << x << "\n"
#define darr(x,n) FOR(i,0,n) cout << #x << "[" << i << "]" << " := " << x[i] << "\n"

typedef long long ll;
typedef long double ld;
typedef pair<int, int > pii;
typedef pair<ll, ll> pll;
//template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T> void minn(T &a, T b) { a = min(a, b); }
template<class T> void maxx(T &a, T b) { a = max(a, b); }

void io() {
#ifdef LOCAL_PROJECT 
	freopen("input.in", "r", stdin); freopen("output.out", "w", stdout);
#else
#endif
	ios_base::sync_with_stdio(false); cin.tie(NULL);
}

const ll INF = 1e14;
/***********************CEOI 2015 D2 Ice*****************************************/
int N;
ll M;
v<ll> A, B;
v<ll> setA, setB;

void gen(v<ll> &stor, v<ll> &nums, int i = 0, ll sum = 0) {
	if (i == nums.size()) {
		stor.push_back(sum);
		return;
	}
	gen(stor, nums, i + 1, sum);
	gen(stor, nums, i + 1, sum + nums[i]);
}

int main() {
	io();
	cin >> N >> M;
	FOR(i, 0, min(20, N)) {
		ll x; cin >> x;
		A.push_back(x);
	}
	FOR(i, 0, max(0, N - 20)) {
		ll x; cin >> x;
		B.push_back(x);
	}
	gen(setA, A), gen(setB, B);
	sort(all(setA)), sort(all(setB));
//	darr(setA, setA.size());
//	darr(setB, setB.size());
	ll ans = 0;
	for (int i = 0, j = setB.size() - 1; i < setA.size(); i++) {
		while (0 <= j && setB[j] + setA[i] > M)
			j--;
		ans += j + 1;
	}
	cout << ans << "\n";
}

Compilation message

bobek.cpp: In function 'void gen(std::vector<long long int>&, std::vector<long long int>&, int, ll)':
bobek.cpp:46:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if (i == nums.size()) {
      ~~^~~~~~~~~~~~~~
bobek.cpp: In function 'int main()':
bobek.cpp:70:41: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0, j = setB.size() - 1; i < setA.size(); i++) {
                                       ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 1532 KB Output is correct
2 Correct 8 ms 1024 KB Output is correct
3 Correct 14 ms 1532 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 6 ms 1024 KB Output is correct
6 Correct 114 ms 8688 KB Output is correct
7 Correct 13 ms 1532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 109 ms 8688 KB Output is correct
2 Correct 27 ms 2552 KB Output is correct
3 Correct 8 ms 1024 KB Output is correct
4 Correct 8 ms 1024 KB Output is correct
5 Correct 71 ms 8688 KB Output is correct
6 Correct 16 ms 1532 KB Output is correct
7 Correct 13 ms 1532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 102 ms 8688 KB Output is correct
2 Correct 142 ms 9568 KB Output is correct
3 Correct 230 ms 20844 KB Output is correct
4 Correct 116 ms 9580 KB Output is correct
5 Correct 67 ms 8688 KB Output is correct
6 Correct 93 ms 8832 KB Output is correct
7 Correct 110 ms 8688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 100 ms 8812 KB Output is correct
2 Correct 109 ms 8688 KB Output is correct
3 Correct 112 ms 12636 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 66 ms 8816 KB Output is correct
6 Correct 99 ms 8688 KB Output is correct
7 Correct 109 ms 8688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 115 ms 9068 KB Output is correct
2 Correct 121 ms 10596 KB Output is correct
3 Correct 128 ms 10588 KB Output is correct
4 Correct 26 ms 2536 KB Output is correct
5 Correct 66 ms 10564 KB Output is correct
6 Correct 181 ms 20820 KB Output is correct
7 Correct 122 ms 10604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 174 ms 16900 KB Output is correct
2 Correct 118 ms 8680 KB Output is correct
3 Correct 111 ms 8688 KB Output is correct
4 Correct 5 ms 768 KB Output is correct
5 Correct 66 ms 8688 KB Output is correct
6 Correct 161 ms 16724 KB Output is correct
7 Correct 113 ms 8688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 118 ms 8640 KB Output is correct
2 Correct 125 ms 9580 KB Output is correct
3 Correct 119 ms 8680 KB Output is correct
4 Correct 115 ms 8688 KB Output is correct
5 Correct 92 ms 10604 KB Output is correct
6 Correct 115 ms 8688 KB Output is correct
7 Correct 221 ms 20828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 215 ms 20832 KB Output is correct
2 Correct 125 ms 8680 KB Output is correct
3 Correct 108 ms 8688 KB Output is correct
4 Correct 235 ms 20820 KB Output is correct
5 Correct 91 ms 12640 KB Output is correct
6 Correct 125 ms 8780 KB Output is correct
7 Correct 112 ms 8812 KB Output is correct