답안 #85969

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
85969 2018-11-23T13:56:56 Z Nordway Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
597 ms 9244 KB
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define boost ios_base::sync_with_stdio(0),cin.tie(0)
#define FILE "divide"

using namespace std;


typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

const int mod=1e9+7;
const int inf=1e9;
const ll INF=1e18;
const ld pi=acos(-1);
const int N=41;

ll a[N];

int main(){
	/*freopen(FILE".in","r",stdin);
	freopen(FILE".out","w",stdout);*/
	int n;
	ll m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int fn=(n+1)/2;
	int sn=n-fn;
	vector<ll>v;
	for(int mask=0;mask<(1<<fn);mask++){
		ll sum=0;
		for(int i=0;i<fn;i++){
			if((mask>>i)&1)sum+=a[i];
		}
		if(sum>m)continue;
		v.pb(sum);
	}
	sort(all(v));
	ll ans=0;
	for(int mask=0;mask<(1<<sn);mask++){
		ll sum=0;
		for(int i=0;i<sn;i++){
			if((mask>>i)&1)sum+=a[fn+i];
		}
		if(sum>m)continue;
		int pos=up_b(all(v),m-sum)-v.begin();
		ans+=pos;
	}
	cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 508 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 2 ms 508 KB Output is correct
6 Correct 2 ms 508 KB Output is correct
7 Correct 2 ms 516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 568 KB Output is correct
2 Correct 2 ms 592 KB Output is correct
3 Correct 2 ms 592 KB Output is correct
4 Correct 2 ms 592 KB Output is correct
5 Correct 2 ms 592 KB Output is correct
6 Correct 2 ms 656 KB Output is correct
7 Correct 2 ms 656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 656 KB Output is correct
2 Correct 2 ms 656 KB Output is correct
3 Correct 2 ms 656 KB Output is correct
4 Correct 2 ms 656 KB Output is correct
5 Correct 3 ms 804 KB Output is correct
6 Correct 2 ms 804 KB Output is correct
7 Correct 2 ms 804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 1836 KB Output is correct
2 Correct 124 ms 2856 KB Output is correct
3 Correct 597 ms 8976 KB Output is correct
4 Correct 121 ms 8976 KB Output is correct
5 Correct 20 ms 8976 KB Output is correct
6 Correct 11 ms 8976 KB Output is correct
7 Correct 11 ms 8976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 8976 KB Output is correct
2 Correct 41 ms 8976 KB Output is correct
3 Correct 255 ms 8976 KB Output is correct
4 Correct 2 ms 8976 KB Output is correct
5 Correct 10 ms 8976 KB Output is correct
6 Correct 20 ms 8976 KB Output is correct
7 Correct 12 ms 8976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 84 ms 8976 KB Output is correct
2 Correct 189 ms 8976 KB Output is correct
3 Correct 181 ms 8976 KB Output is correct
4 Correct 2 ms 8976 KB Output is correct
5 Correct 106 ms 8976 KB Output is correct
6 Correct 348 ms 8976 KB Output is correct
7 Correct 64 ms 8976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 358 ms 8996 KB Output is correct
2 Correct 39 ms 8996 KB Output is correct
3 Correct 14 ms 8996 KB Output is correct
4 Correct 2 ms 8996 KB Output is correct
5 Correct 11 ms 8996 KB Output is correct
6 Correct 267 ms 9080 KB Output is correct
7 Correct 12 ms 9080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 9080 KB Output is correct
2 Correct 123 ms 9080 KB Output is correct
3 Correct 12 ms 9080 KB Output is correct
4 Correct 13 ms 9080 KB Output is correct
5 Correct 118 ms 9080 KB Output is correct
6 Correct 31 ms 9080 KB Output is correct
7 Correct 159 ms 9080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 507 ms 9244 KB Output is correct
2 Correct 38 ms 9244 KB Output is correct
3 Correct 12 ms 9244 KB Output is correct
4 Correct 531 ms 9244 KB Output is correct
5 Correct 162 ms 9244 KB Output is correct
6 Correct 20 ms 9244 KB Output is correct
7 Correct 21 ms 9244 KB Output is correct