#include <bits/stdc++.h>
using namespace std;
#define ll long long
//14:20
int n;
ll m;
ll c[45];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
for(int i = 0; i < n; i++) {
cin >> c[i];
}
if(n <= 21) {
ll ways = 0;
for(int mask = 0; mask < (1<<n); mask++) {
ll money = m;
for(int i = 0; i < n; i++) {
if(mask&(1<<i)) {
money-= c[i];
}
}
if(money >= 0) {
ways++;
}
}
cout << ways;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
360 KB |
Output is correct |
2 |
Correct |
2 ms |
568 KB |
Output is correct |
3 |
Correct |
3 ms |
576 KB |
Output is correct |
4 |
Correct |
3 ms |
576 KB |
Output is correct |
5 |
Correct |
3 ms |
576 KB |
Output is correct |
6 |
Correct |
3 ms |
576 KB |
Output is correct |
7 |
Correct |
3 ms |
616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
652 KB |
Output is correct |
2 |
Correct |
8 ms |
656 KB |
Output is correct |
3 |
Correct |
12 ms |
660 KB |
Output is correct |
4 |
Correct |
2 ms |
664 KB |
Output is correct |
5 |
Correct |
7 ms |
668 KB |
Output is correct |
6 |
Correct |
87 ms |
676 KB |
Output is correct |
7 |
Correct |
14 ms |
676 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
86 ms |
692 KB |
Output is correct |
2 |
Correct |
21 ms |
692 KB |
Output is correct |
3 |
Correct |
7 ms |
692 KB |
Output is correct |
4 |
Correct |
7 ms |
692 KB |
Output is correct |
5 |
Correct |
91 ms |
824 KB |
Output is correct |
6 |
Correct |
12 ms |
824 KB |
Output is correct |
7 |
Correct |
13 ms |
824 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
824 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
824 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
824 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
824 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
824 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
824 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |