#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,m;
unordered_set<string> st;
ll solve(vector<ll> pr,ll curr,string vis) {
if (curr < 0) {
return 0;
}
if (st.find(vis) != st.end()) {
return 0;
}
st.insert(vis);
ll c=1;
for (int i=0;i<n;i++) {
if (vis[i] == '0') {
vis[i] = '1';
c+=solve(pr,curr-pr[i],vis);
vis[i]= '0';
}
}
return c;
}
int main() {
cin.tie(0)->sync_with_stdio(false);
cin >> n >> m;
vector<ll> pr(n);
for (int i=0;i<n;i++) {
cin >> pr[i];
}
cout << solve(pr,m,string(n,'0'));
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
64 ms |
7664 KB |
Output is correct |
2 |
Correct |
25 ms |
3408 KB |
Output is correct |
3 |
Correct |
57 ms |
7004 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
43 ms |
5984 KB |
Output is correct |
6 |
Execution timed out |
1060 ms |
67808 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1038 ms |
66192 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1042 ms |
71100 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1045 ms |
71452 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1024 ms |
69348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1048 ms |
69104 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1029 ms |
70588 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1030 ms |
77584 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |