Submission #738632

#TimeUsernameProblemLanguageResultExecution timeMemory
738632bgnbvnbvIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
305 ms20840 KiB
#include<bits/stdc++.h> #define TASKNAME "codeforce" #define pb push_back #define pli pair<int,int> #define fi first #define se second #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); using namespace std; using ll=long long; const ll maxN=2e5; const ll inf=1e18; const ll mod=1e9+7; ll n,m,a[maxN]; vector<ll>vec1,vec2; void solve() { cin >> n >> m;ll ans=0; for(int i=1;i<=n;i++) cin >> a[i]; ll k=n/2; for(int mask=0;mask<(1<<k);mask++) { ll sum=0; for(int i=0;i<k;i++) { if(mask>>i&1) { sum+=a[i+1]; } } vec1.pb(sum); } for(int mask=0;mask<(1<<(n-k));mask++) { ll sum=0; for(int i=0;i<n-k;i++) { if(mask>>i&1) { sum+=a[i+k+1]; } } vec2.pb(sum); } sort(vec1.begin(),vec1.end()); sort(vec2.begin(),vec2.end()); ll j=0; for(int i=vec1.size()-1;i>=0;i--) { while(j<vec2.size()&&vec2[j]+vec1[i]<=m) j++; ans+=j; } cout << ans; } int main() { fastio //freopen(TASKNAME".INP","r",stdin); //freopen(TASKNAME".OUT","w",stdout); solve(); }

Compilation message (stderr)

bobek.cpp: In function 'void solve()':
bobek.cpp:49:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         while(j<vec2.size()&&vec2[j]+vec1[i]<=m) j++;
      |               ~^~~~~~~~~~~~
#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...