Submission #748649

#TimeUsernameProblemLanguageResultExecution timeMemory
748649mariowongIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
263 ms20844 KiB
#include <bits/stdc++.h> using namespace std; long long n,m,a[55],ans; vector <long long> v,v2; bool vis[55]; void ex(int l,int r,long long sum){ if (l > r){ if (r == n) v2.push_back(sum); else v.push_back(sum); } else { if (sum+a[l] <= m){ vis[l]=true; ex(l+1,r,sum+a[l]); } vis[l]=false; ex(l+1,r,sum); } } int main(){ ios::sync_with_stdio(false); // freopen(".in","r",stdin); // freopen(".out","w",stdout); cin >> n >> m; for (int i=1;i<=n;i++){ cin >> a[i]; } ex(1,n/2,0); ex(n/2+1,n,0); sort(v.begin(),v.end()); sort(v2.begin(),v2.end()); for (int i=0;i<v.size();i++){ ans+=lower_bound(v2.begin(),v2.end(),m-v[i]+1)-v2.begin(); } cout << ans << "\n"; return 0; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:36:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |  for (int i=0;i<v.size();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...