Submission #109352

#TimeUsernameProblemLanguageResultExecution timeMemory
109352dupreezIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
488 ms16888 KiB
#include <iostream> #include <algorithm> #include <cstring> #include <sstream> #include <map> #include <queue> #include <vector> #include <deque> #include <climits> #define scanf scanf_s #define mk make_pair #define pb push_back using namespace std; typedef long long int ll; typedef pair<ll, ll> pos; const ll MOD = 1000000007, N = 2010.; ll n, m,l1[1<<20],l2[1<<20],a1[20],a2[20],n1,n2,ans; int main() { cin >> n >> m; n1 = n / 2; n2 = n - n1; for (int i = 0; i < n1; i++)cin >> a1[i]; for (int i = 0; i < n2; i++)cin >> a2[i]; for (int s = 0; s < (1 << n1); s++) { for (int i = 0; i < n1; i++) { l1[s] += a1[i] * ((s >> i) & 1); } } for (int s = 0; s < (1 << n2); s++) { for (int i = 0; i < n2; i++) { l2[s] += a2[i] * ((s >> i) & 1); } } sort(l2, l2 + (1 << n2)); for (int i = 0; i < (1 << n1); i++) { ll v1 = m - l1[i]; ans += upper_bound(l2, l2 + (1 << n2), v1) - l2; } 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...