第三题45%错都不知道错哪了求大佬指点……


import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
{
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int sum = 0;
ArrayList<Long> objects = new ArrayList<>();
ArrayList<Long> objects2 = new ArrayList<>();
for (int i = 0; i < n; i++) {
Long x = in.nextLong();
sum += x;
objects.add(x);
}
if (objects.get(0) % 2 != 0 || objects.get(0) > 0) {
objects2.add(0L);
} else {
objects2.add(objects.get(0));
}
for (int i = 1; i < n; i++) {
if (objects.get(i) % 2 != 0 || objects.get(i) + objects2.get(i - 1) > 0) {
objects2.add(0L);
} else {
Long num = objects.get(i) + objects2.get(i - 1);
objects2.add(num);
}
}
Long[] objects1 = objects2.toArray(new Long[0]);
Arrays.sort(objects1);
if (objects1.length > 0) {
Long nn = objects1[0];
System.out.println(sum - (nn / 2));
} else {
System.out.println(0);
}
}
}
}
// 游游拿到了n个正整数a_i,她希望你求出这些数的阶乘全部乘在一起生成的大数有多少个因子。你能帮帮她吗?