답안 #155004

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
155004 2019-09-25T20:49:04 Z TadijaSebez Ice Hockey World Championship (CEOI15_bobek) C++11
100 / 100
442 ms 16892 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int N=43;
ll a[N],K;
int n;
vector<ll> Build(int l, int r)
{
	int sz=r-l+1;
	vector<ll> ans;
	ans.reserve(1<<sz);
	for(int mask=0;mask<1<<sz;mask++)
	{
		ll sum=0;
		for(int i=0;i<sz;i++) if(mask>>i&1) sum+=a[l+i];
		ans.pb(sum);
	}
	sort(ans.begin(),ans.end());
	return ans;
}
int main()
{
	scanf("%i %lld",&n,&K);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	int m=n/2;
	vector<ll> L,R;
	L=Build(1,m);
	R=Build(m+1,n);
	ll ans=0;
	for(int i=0;i<L.size();i++)
	{
		int j=upper_bound(R.begin(),R.end(),K-L[i])-R.begin();
		ans+=j;
	}
	printf("%lld\n",ans);
	return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:31:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<L.size();i++)
              ~^~~~~~~~~
bobek.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %lld",&n,&K);
  ~~~~~^~~~~~~~~~~~~~~~~
bobek.cpp:25:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
                        ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 1912 KB Output is correct
2 Correct 102 ms 4480 KB Output is correct
3 Correct 442 ms 16684 KB Output is correct
4 Correct 102 ms 4404 KB Output is correct
5 Correct 19 ms 1400 KB Output is correct
6 Correct 12 ms 888 KB Output is correct
7 Correct 23 ms 1400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 2424 KB Output is correct
2 Correct 36 ms 1912 KB Output is correct
3 Correct 174 ms 8592 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 10 ms 888 KB Output is correct
6 Correct 24 ms 1400 KB Output is correct
7 Correct 23 ms 1400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 3460 KB Output is correct
2 Correct 149 ms 6520 KB Output is correct
3 Correct 149 ms 6540 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 100 ms 6608 KB Output is correct
6 Correct 382 ms 16888 KB Output is correct
7 Correct 140 ms 6520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 309 ms 12664 KB Output is correct
2 Correct 35 ms 1912 KB Output is correct
3 Correct 13 ms 888 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 10 ms 764 KB Output is correct
6 Correct 299 ms 12768 KB Output is correct
7 Correct 22 ms 1400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 1912 KB Output is correct
2 Correct 101 ms 4480 KB Output is correct
3 Correct 13 ms 888 KB Output is correct
4 Correct 13 ms 888 KB Output is correct
5 Correct 106 ms 6468 KB Output is correct
6 Correct 34 ms 1952 KB Output is correct
7 Correct 392 ms 16888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 420 ms 16892 KB Output is correct
2 Correct 36 ms 1912 KB Output is correct
3 Correct 13 ms 888 KB Output is correct
4 Correct 434 ms 16824 KB Output is correct
5 Correct 148 ms 8568 KB Output is correct
6 Correct 24 ms 1400 KB Output is correct
7 Correct 46 ms 2680 KB Output is correct