Submission #572622

#TimeUsernameProblemLanguageResultExecution timeMemory
572622vladislav11Ice Hockey World Championship (CEOI15_bobek)C++14
100 / 100
333 ms21032 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int n; ll m; vector<ll> a; void f ( vector<ll> &x, vector<ll> &v ) { int m = x.size(); for ( int i=0; i < (1<<m); i++ ) { ll sum = 0; for ( int j=0; j<m; j++ ) if ( (i>>j) & 1 ) sum += x[j]; v.push_back( sum ); } } int main () { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; a.resize(n); for ( auto& el : a ) cin >> el; vector<ll> x, y; { int m = n/2; for ( int i=0; i<m; i++ ) x.push_back( a[i] ); for ( int i=m; i<n; i++ ) y.push_back( a[i] ); } vector<ll> p, q; f( x, p ); f( y, q ); sort( p.begin(), p.end() ); sort( q.begin(), q.end() ); ll ans = 0; for ( auto& el : q ) { ll w = m - el; int l = -1, r = int(p.size())-1; while ( l < r ) { int mid = ( l + r + 1 ) / 2; if ( p[mid] <= w ) l = mid; else r = mid-1; } ans += l+1; } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...