Submission #118780

#TimeUsernameProblemLanguageResultExecution timeMemory
118780silxikysIce Hockey World Championship (CEOI15_bobek)C++14
40 / 100
1082 ms64504 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> const int maxn = 45; template <class K, class V = __gnu_pbds::null_type> using ordered_multiset = __gnu_pbds::tree<K, V, std::less_equal<K>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>; int N; ll M; ll A[maxn], B[maxn]; int main() { cin >> N >> M; int split = N/2; for (int i = 0; i < split; i++) { cin >> A[i]; } for (int i = split; i < N; i++) { cin >> B[i-split]; } ordered_multiset<ll> s; for (int i = 0; i < (1<<split); i++) { ll total = 0; for (int j = 0; j < split; j++) { if (i & (1<<j)) total += A[j]; } s.insert(total); } ll ans = 0; for (int i = 0; i < (1<<(N-split)); i++) { ll total = 0; for (int j = 0; j < N-split; j++) { if (i & (1<<j)) total += B[j]; } if (total <= M) { ans += s.order_of_key(M-total+1); } } cout << ans << '\n'; }
#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...