| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1367417 | jbn8 | Bootfall (IZhO17_bootfall) | C++20 | 1 ms | 1604 KiB |
#include <cstdio>
#include <array>
using namespace std;
const int maxN = 500;
const int maxA = 501;
int main(){
int N;
scanf("%d\n", &N);
array<int, maxN+1> a{};
int sum = 0;
for(int i=0; i<N; i++){
scanf("%d", &a[i]);
sum += a[i];
}
array<int, maxA*maxN> poss;
array<bool, maxN*maxA/2> cache{};
cache[0] = true;
for(int i=0; i<N+1; i++){
int part = sum-a[i];
if(i){
int idp = i-1;
for(int j=part/2-a[idp]; j >= 0; j--){
if(cache[j]){
cache[j+a[idp]] = true;
}
}
}
array<bool, maxN*maxA/2> possreferee = cache;
for(int idp=i+1; idp<N; idp++){
for(int j=part/2-a[idp]; j >= 0; j--){
if(possreferee[j]){
possreferee[j+a[idp]] = true;
}
}
}
if(i == N && !possreferee[part/2]){
printf("0\n");
return 0;
}
if(i == N)continue;
for(int idw=0; idw<=part/2; idw++){
if(possreferee[idw]){
poss[part-idw*2]++;
}
}
}
int count = 0;
for(int i=0; i<sum; i++)
count += poss[i] == N;
printf("%d\n", count);
for(int i=0; i<sum; i++){
if(poss[i] == N){
printf("%d ", i);
}
}
printf("\n");
}Compilation message (stderr)
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
