import java.util.Scanner;
public class P2392 {
static int[] s = new int[4];
static int[][] a = new int[4][20];
static int left,right,min,ans=0;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
for(int i=0;i<4;i++) {
s[i] = sc.nextInt();
}
for(int i=0;i<4;i++) {
for(int j=0;j<s[i];j++) {
a[i][j] = sc.nextInt();
}
}
for(int i=0;i<4;i++) {
left=right=0;
min = 5000;
dfs(i,0);
ans += min;
}
System.out.println(ans);
}
private static void dfs(int i, int y) {
if(y>=s[i]) {
min =Math.min(min, Math.max(left, right)) ;
return ;
}
left += a[i][y];
dfs(i,y+1);
left -= a[i][y];
right += a[i][y];
dfs(i,y+1);
right -= a[i][y];
}
}
PP2392 考前临时抱佛脚(递归+搜索)
猜你喜欢
转载自blog.csdn.net/qq_28635317/article/details/115174882
今日推荐
周排行