Submission #1121573

#TimeUsernameProblemLanguageResultExecution timeMemory
1121573vjudge1Ice Hockey World Championship (CEOI15_bobek)C++14
10 / 100
73 ms8636 KiB
//#pragma GCC optimize ("O1") #include <bits/stdc++.h> using namespace std; #define endl '\n' #define pb push_back #define F first #define S second #define ll long long #define int ll #define pii pair<int, int> #define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define M_PI 3.14159265358979323846 #define all(v) v.begin(), v.end() #define pss pair<string, string> #define no cout<<"NO"<<endl; #define yes cout<<"YES"<<endl; #define imp cout<<-1<<endl; #define flu cout.flush(); #define Endl endl const int N = 300009; const int mod = 1e9+7; void solve(){ int n, k; cin>>n>>k; vector<int>a; for(int i=0; i<n; i++){ int x; cin>>x; a.pb(x); } int sum=0, mid1=n/2, mid2=n-mid2; vector<int>sums; for(int i=0; i<(1<<mid1); i++){ sum=0; int yx=0; for(int j=0; j<mid1; j++){ if(i&(1<<j)){ sum+=a[j]; } } sums.pb(sum); } int ans=0; for(int i=0; i<(1<<mid2); i++){ int sum=0, yx=0; for(int j=0; j<mid2; j++){ if(i&(1<<j)){ sum+=a[j+mid1]; } } int q=0; q=upper_bound(all(sums), k-sum)-sums.begin(); ans+=q; } cout<<ans<<endl; } signed main(){ io; int t=1; //cin>>t; while(t--){ solve(); } }

Compilation message (stderr)

bobek.cpp: In function 'void solve()':
bobek.cpp:39:13: warning: unused variable 'yx' [-Wunused-variable]
   39 |         int yx=0;
      |             ^~
bobek.cpp:49:20: warning: unused variable 'yx' [-Wunused-variable]
   49 |         int sum=0, yx=0;
      |                    ^~
bobek.cpp:35:26: warning: 'mid2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   35 |     int sum=0, mid1=n/2, mid2=n-mid2;
      |                          ^~~~
#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...