Submission #491453

#TimeUsernameProblemLanguageResultExecution timeMemory
491453Yazan_AlattarIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
448 ms8680 KiB
#include <iostream> #include <fstream> #include <vector> #include <cstring> #include <algorithm> #include <set> #include <map> #include <queue> #include <list> #include <utility> #include <cmath> #include <numeric> using namespace std; typedef long long ll; #define F first #define S second #define pb push_back #define endl "\n" #define all(x) x.begin(), x.end() const int M = 200007; const ll inf = 1e18; const ll mod = 1e9 + 7; const double pi = acos(-1); const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}; vector <ll> v; ll n, m, a[50], ans; int main() { ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n >> m; for(int i = 0; i < n; ++i) cin >> a[i]; for(int mask = 0; mask < (1 << (n / 2)); ++mask){ ll sum = 0; for(int i = 0; i < n / 2; ++i) if((mask >> i) & 1) sum += a[i]; v.pb(sum); } sort(all(v)); for(int mask = 0; mask < (1 << ((n + 1) / 2)); ++mask){ ll sum = 0; for(int i = n / 2; i < n; ++i) if((mask >> (i - n / 2)) & 1) sum += a[i]; ans += upper_bound(all(v), m - sum) - v.begin(); } cout << ans << endl; return 0; } // Don't forget special cases. (n = 1?) // Look for the constraints. (Runtime array? overflow?)
#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...