#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#include "xylophone.h"
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl "\n"
int mod=1e9+7;
int N=2e5+5;
template<class x>
using ordered_multiset = tree<x, null_type,less_equal<x>, rb_tree_tag,tree_order_statistics_node_update>;
int n,ttl,tmpttl;
vector<int> ans;
int v[3005];
int dp[20][3000];
int solve(int i,int sum) {
if (i==n+1) return abs(sum-abs(tmpttl-sum));
if (dp[i][sum]!=-1) return dp[i][sum];
int op1=solve(i+1,sum);
int op2=solve(i+1,sum+v[i]);
return dp[i][sum]=min(op1,op2);
}
signed main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen(".in", "r", stdin); freopen(".out", "w", stdout);
cin>>n;
for (int i=0;i<n;i++) {
cin>>v[i];
ttl+=v[i];
}
for (int i=1;i<=3000;i++) {
v[n]=i; ttl++;
bool bl=true;
for (int j=0;j<=n;j++) {
memset(dp,-1,sizeof dp);
int tmp=v[j]; v[j]=0;
tmpttl=ttl-tmp;
int cl=solve(0,0);
v[j]=tmp;
if (cl!=0) {
bl=false; break;
}
}
if (bl) ans.push_back(i);
}
cout<<ans.size()<<endl;
for (int i:ans) cout<<i<<' ';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
724 KB |
Output is correct |
2 |
Correct |
34 ms |
724 KB |
Output is correct |
3 |
Correct |
32 ms |
792 KB |
Output is correct |
4 |
Correct |
34 ms |
724 KB |
Output is correct |
5 |
Correct |
161 ms |
772 KB |
Output is correct |
6 |
Correct |
39 ms |
724 KB |
Output is correct |
7 |
Correct |
34 ms |
768 KB |
Output is correct |
8 |
Correct |
142 ms |
724 KB |
Output is correct |
9 |
Correct |
58 ms |
724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
724 KB |
Output is correct |
2 |
Correct |
34 ms |
724 KB |
Output is correct |
3 |
Correct |
32 ms |
792 KB |
Output is correct |
4 |
Correct |
34 ms |
724 KB |
Output is correct |
5 |
Correct |
161 ms |
772 KB |
Output is correct |
6 |
Correct |
39 ms |
724 KB |
Output is correct |
7 |
Correct |
34 ms |
768 KB |
Output is correct |
8 |
Correct |
142 ms |
724 KB |
Output is correct |
9 |
Correct |
58 ms |
724 KB |
Output is correct |
10 |
Execution timed out |
1085 ms |
804 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
724 KB |
Output is correct |
2 |
Correct |
34 ms |
724 KB |
Output is correct |
3 |
Correct |
32 ms |
792 KB |
Output is correct |
4 |
Correct |
34 ms |
724 KB |
Output is correct |
5 |
Correct |
161 ms |
772 KB |
Output is correct |
6 |
Correct |
39 ms |
724 KB |
Output is correct |
7 |
Correct |
34 ms |
768 KB |
Output is correct |
8 |
Correct |
142 ms |
724 KB |
Output is correct |
9 |
Correct |
58 ms |
724 KB |
Output is correct |
10 |
Execution timed out |
1085 ms |
804 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
724 KB |
Output is correct |
2 |
Correct |
34 ms |
724 KB |
Output is correct |
3 |
Correct |
32 ms |
792 KB |
Output is correct |
4 |
Correct |
34 ms |
724 KB |
Output is correct |
5 |
Correct |
161 ms |
772 KB |
Output is correct |
6 |
Correct |
39 ms |
724 KB |
Output is correct |
7 |
Correct |
34 ms |
768 KB |
Output is correct |
8 |
Correct |
142 ms |
724 KB |
Output is correct |
9 |
Correct |
58 ms |
724 KB |
Output is correct |
10 |
Execution timed out |
1085 ms |
804 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
724 KB |
Output is correct |
2 |
Correct |
34 ms |
724 KB |
Output is correct |
3 |
Correct |
32 ms |
792 KB |
Output is correct |
4 |
Correct |
34 ms |
724 KB |
Output is correct |
5 |
Correct |
161 ms |
772 KB |
Output is correct |
6 |
Correct |
39 ms |
724 KB |
Output is correct |
7 |
Correct |
34 ms |
768 KB |
Output is correct |
8 |
Correct |
142 ms |
724 KB |
Output is correct |
9 |
Correct |
58 ms |
724 KB |
Output is correct |
10 |
Execution timed out |
1085 ms |
804 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
724 KB |
Output is correct |
2 |
Correct |
34 ms |
724 KB |
Output is correct |
3 |
Correct |
32 ms |
792 KB |
Output is correct |
4 |
Correct |
34 ms |
724 KB |
Output is correct |
5 |
Correct |
161 ms |
772 KB |
Output is correct |
6 |
Correct |
39 ms |
724 KB |
Output is correct |
7 |
Correct |
34 ms |
768 KB |
Output is correct |
8 |
Correct |
142 ms |
724 KB |
Output is correct |
9 |
Correct |
58 ms |
724 KB |
Output is correct |
10 |
Execution timed out |
1085 ms |
804 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |