Submission #963421

#TimeUsernameProblemLanguageResultExecution timeMemory
963421pccIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
302 ms21064 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll,ll> #define pii pair<int,int> #define fs first #define sc second #define tlll tuple<ll,ll,ll> const int mxn = 40; ll N,M; vector<ll> lv,rv; vector<ll> la,ra; void calc(vector<ll> &v,vector<ll>& all){ for(int i = 0;i<(1<<v.size());i++){ ll sum = 0; for(int j = 0;j<v.size();j++){ if(i&(1<<j))sum += v[j]; } all.push_back(sum); } sort(all.begin(),all.end()); return; } int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>N>>M; for(int i = 0;i<N/2;i++){ ll k; cin>>k; la.push_back(k); } for(int i = N/2;i<N;i++){ ll k; cin>>k; ra.push_back(k); } calc(la,lv); calc(ra,rv); ll pt = 0; ll ans = 0; reverse(lv.begin(),lv.end()); for(auto &i:lv){ while(pt<rv.size()&&rv[pt]+i<=M)pt++; ans += pt; } cout<<ans<<'\n'; return 0; }

Compilation message (stderr)

bobek.cpp: In function 'void calc(std::vector<long long int>&, std::vector<long long int>&)':
bobek.cpp:20:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for(int j = 0;j<v.size();j++){
      |                 ~^~~~~~~~~
bobek.cpp: In function 'int main()':
bobek.cpp:48:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |   while(pt<rv.size()&&rv[pt]+i<=M)pt++;
      |         ~~^~~~~~~~~~
#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...