阿巴阿巴。。。
#include <stdio.h>
using namespace std;
int task[5][70];
int main(){
int s[5];
scanf("%d %d %d %d", s + 1, s + 2, s + 3, s + 4);
for(int i = 1; i <= 4; i ++){
for(int j = 1; j <= s[i]; j ++){
scanf("%d", &task[i][j]);
}
}
int time = 0;
for(int i = 1; i <= 4; i ++){
int volume = 0;
for(int j = 1; j <= s[i]; j ++){
volume += task[i][j];
}
int temp = volume;
volume /= 2;
int table[s[i] + 2][volume + 2];
for(int j = 0; j <= volume; j ++) table[0][j] = 0;
for(int j = 0; j <= s[i]; j ++) table[j][0] = 0;
for(int x = 1; x <= s[i]; x ++){
for(int y = 1; y <= volume; y ++){
table[x][y] = task[i][x] > y ? table[x - 1][y] : (task[i][x] + table[x][y - task[i][x]] > table[x - 1][y] ? task[i][x] + table[x][y - task[i][x]] : table[x - 1][y]);
}
}
time += temp - table[s[i]][volume];
}
printf("%d\n", time);
return 0;
}