#include <bits/stdc++.h>
using namespace std;
int main(){
int t, n, sum, op;
cin >> t;
vector<int> a;
vector<int> lasti;
vector<bool> k;
while (t--){
cin >> n;
a.resize(n);
lasti.assign(50001, -1);
k.assign(n+1, true);
k[0] = false;
for (int i=0; i<n; i++){
cin >> a[i];
for (int j=50000-a[i]; j>0; j--){
lasti[j + a[i]] = max(lasti[j + a[i]], lasti[j]);
}
if (a[i] <= 50000){
lasti[a[i]] = i;
}
sum = 0;
for (int j=i; j>=0; j--){
sum += a[j];
if (sum % 2 || lasti[sum / 2] < j){
k[i - j + 1] = false;
}
}
}
op = 0;
for (int x : k){
if (x){
op++;
}
}
cout << op << " ";
for (int i=1; i<n+1; i++){
if (k[i]){
cout << i << " ";
}
}
cout << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
71 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
141 ms |
504 KB |
Output is correct |
2 |
Correct |
378 ms |
480 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
737 ms |
492 KB |
Output is correct |
2 |
Correct |
1351 ms |
620 KB |
Output is correct |
3 |
Correct |
1145 ms |
492 KB |
Output is correct |
4 |
Correct |
1903 ms |
508 KB |
Output is correct |
5 |
Execution timed out |
2074 ms |
640 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |