Submission #161817

#TimeUsernameProblemLanguageResultExecution timeMemory
161817dantoh000Ice Hockey World Championship (CEOI15_bobek)C++14
100 / 100
456 ms8700 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ int n; ll m; scanf("%d%lld",&n,&m); ll a[n]; for (int i = 0; i < n; i++) scanf("%lld",&a[i]); int ct = 0; int k = min(20,n-1); vector<ll> v(1<<k); for (int i = 0; i < (1<<k); i++){ int cur = i; ll sum = 0; while (cur){ int lsb = (cur)&(-cur); sum += a[__builtin_ctz(lsb)]; cur -= lsb; } v[i] = sum; } sort(v.begin(),v.end()); ll ans = 0; for (int i = 0; i < (1<<(n-k)); i++){ int cur = i; ll sum = 0; while (cur){ int lsb = (cur)&(-cur); sum += a[__builtin_ctz(lsb)+k]; cur -= lsb; } //printf("%d %lld %lld\n",i,sum,(ll)(upper_bound(v.begin(),v.end(),m-sum)-v.begin())); ans += upper_bound(v.begin(),v.end(),m-sum)-v.begin(); } printf("%lld\n",ans); }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:10:9: warning: unused variable 'ct' [-Wunused-variable]
     int ct = 0;
         ^~
bobek.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%lld",&n,&m);
     ~~~~~^~~~~~~~~~~~~~~~
bobek.cpp:9:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 0; i < n; i++) scanf("%lld",&a[i]);
                                 ~~~~~^~~~~~~~~~~~~~
#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...