Submission #1005047

#TimeUsernameProblemLanguageResultExecution timeMemory
1005047RifalIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
380 ms10544 KiB
#include <bits/stdc++.h> #include <fstream> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #define endl '\n' #define mod 1000000007 #define INF 1000000000 #define INF2 2000000000 #define fi first #define se second using namespace std; double const EPS = 1e-14; const int P = 1007; typedef long long ll; using namespace __gnu_pbds; typedef long long ll; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key map<ll,ll> mp; int main() { ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); int n; cin >> n; ll val; cin >> val; ll arr[n]; for(int i = 0; i < n; i++) cin >> arr[i]; int mid = n/2; vector<ll> v; for(int i = 0; i < (1<<mid); i++) { ll sum = 0; for(int j = 0; j < mid; j++) { if((i&(1<<j)) > 0) { sum += arr[j]; } } v.push_back(sum); } sort(v.begin(),v.end()); ll ans = 0; for(int i = 0; i < (1<<(n-mid)); i++) { ll sum = 0; for(int j = 0; j < (n-mid); j++) { if((i&(1<<j)) > 0) { sum += arr[j+mid]; } } int indx = upper_bound(v.begin(),v.end(),val-sum)-v.begin(); ans += indx; } cout << ans << endl; return 0; }
#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...