답안 #1110539

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1110539 2024-11-09T21:10:20 Z omar1312 Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
308 ms 25008 KB
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()
const int mod = 1000000007;
const int N = 200005;
ll a[N+2], dp[N+2];
void solve(){
	ll n, k;
	cin>>n>>k;
	for(int i = 0; i < n; i++){
		cin>>a[i];
	}
	ll dumb = n / 2, dumb2 = n - dumb;
	vector<ll> v1, v2;
	for(int i = 0; i < (1 << dumb); i++){
		ll cost = 0;
		for(int j = 0; j < dumb; j++){
			if((i >> j) & 1){
				cost += a[j];
			}
		}
		v1.pb(cost);
	}
	for(int i = 0; i < (1 << dumb2); i++){
		ll cost = 0;
		for(int j = 0; j < dumb2; j++){
			if((i >> j) & 1){
				cost += a[j + dumb];
			}
		}
		v2.pb(cost);
	}
	sort(all(v1));
	sort(all(v2));
	ll ans = 0;
	for(auto i : v1){
		if(i > k)break;
		auto it = upper_bound(all(v2), k - i);
		--it;
		ans += it - v2.begin() + 1;
	}
	cout<<ans;
}
int main(){
cin.tie(0)->sync_with_stdio(0);
	int tt = 1;
	//cin>>tt;
	while(tt--){
		solve();
		cout<<'\n';
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 2 ms 2640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 4180 KB Output is correct
2 Correct 73 ms 8648 KB Output is correct
3 Correct 304 ms 24932 KB Output is correct
4 Correct 81 ms 8612 KB Output is correct
5 Correct 13 ms 3792 KB Output is correct
6 Correct 9 ms 3168 KB Output is correct
7 Correct 16 ms 3804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 5068 KB Output is correct
2 Correct 32 ms 4180 KB Output is correct
3 Correct 128 ms 14788 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 7 ms 3152 KB Output is correct
6 Correct 17 ms 3792 KB Output is correct
7 Correct 20 ms 3664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 6736 KB Output is correct
2 Correct 109 ms 10844 KB Output is correct
3 Correct 106 ms 10840 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 74 ms 10828 KB Output is correct
6 Correct 253 ms 25008 KB Output is correct
7 Correct 95 ms 10852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 215 ms 16808 KB Output is correct
2 Correct 26 ms 4352 KB Output is correct
3 Correct 11 ms 3152 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 7 ms 3152 KB Output is correct
6 Correct 204 ms 16860 KB Output is correct
7 Correct 16 ms 3792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 4180 KB Output is correct
2 Correct 73 ms 8640 KB Output is correct
3 Correct 9 ms 3320 KB Output is correct
4 Correct 9 ms 3140 KB Output is correct
5 Correct 74 ms 10856 KB Output is correct
6 Correct 25 ms 4180 KB Output is correct
7 Correct 252 ms 25008 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 283 ms 24920 KB Output is correct
2 Correct 29 ms 4180 KB Output is correct
3 Correct 11 ms 3168 KB Output is correct
4 Correct 308 ms 25008 KB Output is correct
5 Correct 109 ms 14776 KB Output is correct
6 Correct 18 ms 3792 KB Output is correct
7 Correct 33 ms 5236 KB Output is correct