#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, 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';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
86 ms |
4380 KB |
Output is correct |
2 |
Correct |
459 ms |
16872 KB |
Output is correct |
3 |
Execution timed out |
1074 ms |
57720 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
145 ms |
8568 KB |
Output is correct |
2 |
Correct |
80 ms |
4472 KB |
Output is correct |
3 |
Execution timed out |
1067 ms |
33256 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
216 ms |
8572 KB |
Output is correct |
2 |
Correct |
659 ms |
16864 KB |
Output is correct |
3 |
Correct |
632 ms |
16772 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
287 ms |
16840 KB |
Output is correct |
6 |
Execution timed out |
1074 ms |
56124 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
938 ms |
33272 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
80 ms |
4456 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1068 ms |
66056 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |