Submission #813067

#TimeUsernameProblemLanguageResultExecution timeMemory
813067JakobZorzIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
302 ms20812 KiB
#include <iostream> #include <vector> #include <queue> #include <algorithm> #include <set> #include <stack> #include <limits.h> #include <math.h> #include <iomanip> #include <bitset> #include <unordered_map> #include <unordered_set> #include <map> #include <cstring> #include <sstream> #pragma GCC target("popcnt") typedef long long ll; typedef long double ld; using namespace std; const int MOD=1e9+7; typedef pair<ll,ll>point; //#define x first //#define y second ll arr1[20]; ll arr2[20]; int n; ll m; int n1,n2; int main(){ ios::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL); cin>>n>>m; n1=n/2; n2=n-n/2; for(int i=0;i<n1;i++) cin>>arr1[i]; for(int i=0;i<n2;i++) cin>>arr2[i]; vector<ll>values1; for(int bits1=0;bits1<(1<<n1);bits1++){ ll val=0; for(int i=0;i<n1;i++) if(bits1&(1<<i)) val+=arr1[i]; values1.push_back(val); } sort(values1.begin(),values1.end()); vector<ll>values2; for(int bits2=0;bits2<(1<<n2);bits2++){ ll val=0; for(int i=0;i<n2;i++) if(bits2&(1<<i)) val+=arr2[i]; values2.push_back(val); } sort(values2.begin(),values2.end()); ll res=0; int i=(int)values2.size(); for(ll val:values1){ while(i>0&&values2[i-1]+val>m) i--; res+=i; } cout<<res<<"\n"; return 0; } /* 5 1000 100 1500 500 500 1000 */
#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...