#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <iomanip>
#include <unordered_map>
#define SWS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define ppb pop_back
#define ft first
#define sd second
#define readf freopen("input.txt", "r", stdin)
#define writef freopen("output.txt", "w", stdout)
#define files readf; writef
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int Z = 999;
const int N = (int)1e6 + 228;
const int INF = (int)1e9 + 5;
const int MOD = (int)1e9 + 7;
int main() {
SWS;
srand(time(0));
//files;
int n, sum = 0;
cin >> n;
vector<int> a(n + 2);
for (int i = 1; i <= n; i++) {
cin >> a[i];
sum += a[i];
}
vector<int> ans;
for (a[n + 1] = 0; a[n + 1] <= sum; a[n + 1]++) {
bool flag = true;
//cout << a[n + 1] << endl;
for (int i = 1; i <= n + 1; i++) {
vector<int> v;
int cur_sum = 0;
for (int j = 1; j < i; j++) {
v.pb(a[j]);
cur_sum += a[j];
}
for (int j = i + 1; j <= n + 1; j++) {
v.pb(a[j]);
cur_sum += a[j];
}
bool nf = false;
for (int mask = 0; mask < (1 << n); mask++) {
int kek = 0;
for (int j = 0; j < n; j++) {
if ((mask >> j) & 1) kek += v[j];
}
if (kek * 2 == cur_sum) nf = true;
}
flag &= nf;
}
if (flag) {
ans.pb(a[n + 1]);
}
}
cout << ans.size() << "\n";
for (int i : ans) {
cout << i << ' ';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Execution timed out |
1078 ms |
252 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Execution timed out |
1078 ms |
252 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Execution timed out |
1078 ms |
252 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Execution timed out |
1078 ms |
252 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Execution timed out |
1078 ms |
252 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Execution timed out |
1078 ms |
252 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |