题目描述
仅供参考
样例
import java.io.*;
import java.util.*;
public class Main {
static int N = 110;
static int[] cnt = new int[N];
static int[] decline = new int[N];
static int[] time = new int[N];
static int[] speed = new int[N];
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
String[] s = br.readLine().split(" ");
for (int i = 1; i <= n; i++) {
cnt[i] = Integer.parseInt(s[i - 1]);
}
String[] s1 = br.readLine().split(" ");
for (int i = 1; i <= n; i++) {
decline[i] = Integer.parseInt(s1[i - 1]);
}
String[] s2 = br.readLine().split(" ");
for (int i = 1; i < n; i++) {
time[i] = Integer.parseInt(s2[i - 1]);
time[i] += time[i - 1];
}
int end = Integer.parseInt(br.readLine());
int res = 0;
for (int i = 1; i <= n; i++) {
res = Math.max(res, help(i, end - time[i - 1]));
}
System.out.println(res);
}
private static int help(int n, int t) {
Arrays.fill(speed, 0);
int res = 0;
for (int i = 0; i < t; i++) {
int temp = 1;
for (int j = 1; j <= n; j++) {
if (get(j) > get(temp)) {
temp = j;
}
}
res += get(temp);
speed[temp]++;
}
return res;
}
private static int get(int x) {
return Math.max(0, cnt[x] - decline[x] * speed[x]);
}
}