Submission #560680

#TimeUsernameProblemLanguageResultExecution timeMemory
560680uroskIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
385 ms20880 KiB
// __builtin_popcount(x) // __builtin_popcountll(x) #define here cerr<<"===========================================\n" #include <bits/stdc++.h> #define ld double #define ll long long #define ull unsigned long long #define llinf 100000000000000000LL // 10^17 #define iinf 2000000000 // 2*10^9 #define pb push_back #define popb pop_back #define fi first #define sc second #define endl '\n' #define pii pair<int,int> #define pll pair<ll,ll> #define pld pair<ld,ld> #define sz(a) int(a.size()) #define all(a) a.begin(),a.end() #define ceri(a,l,r) {for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;} using namespace std; #define maxn 45 ll n,m; ll a[maxn]; vector<ll> get(ll l,ll r){ vector<ll> v; ll siz = r-l+1; for(ll mask = 0;mask<(1<<siz);mask++){ ll sum = 0; for(ll i = 0;i<siz;i++) if((1<<i)&mask) sum+=a[i+l]; v.pb(sum); } sort(all(v)); return v; } int main(){ ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0); cin >> n >> m; for(ll i = 1;i<=n;i++) cin >> a[i]; ll mid = (n+1)/2; vector<ll> ls = get(1,mid); vector<ll> rs = get(mid+1,n); ll ans = 0; for(ll x : ls){ ll i = upper_bound(all(rs),m-x) - rs.begin(); ans+=i; } cout<<ans<<endl; 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...