关注
import java.util.*;
public class First {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int n = cin.nextInt();
int[] weight = new int[n];
int[] time = new int[n];
for (int i = 0; i < n; i++) {
weight[i] = cin.nextInt();
}
for (int i = 0; i < n; i++) {
time[i] = cin.nextInt();
}
int[] a = {100, 80, 60};
int index = 0;
Map<Integer, List<Integer[]>> map = new HashMap<>();
for (int j = 0; j <= 60; j++) {
if (index < time.length &;&; j != time[index]) continue;
if (map.containsKey(j)) {
List<Integer[]> tmpM = map.get(j);
for (Integer[] is: tmpM) a[is[1]] += weight[is[0]];
map.remove(j);
}
while (index < time.length &;&; j >= time[index]) {
if (a[0] >= weight[index]) {
a[0] -= weight[index];
List<Integer[]> tmpM = map.get(30 + time[index]);
if (tmpM == null) {
List<Integer[]> list = new ArrayList<>();
list.add(new Integer[]{index, 0});
map.put(30 + time[index], list);
}else{
tmpM.add(new Integer[]{index, 0});
}
index++;
} else if (a[1] >= weight[index]) {
a[1] -= weight[index];
List<Integer[]> tmpM = map.get(30 + time[index]);
if (tmpM == null) {
List<Integer[]> list = new ArrayList<>();
list.add(new Integer[]{index, 1});
map.put(30 + time[index], list);
}else{
tmpM.add(new Integer[]{index, 1});
}
index++;
} else if (a[2] >= weight[index]) {
a[2] -= weight[index];
List<Integer[]> tmpM = map.get(30 + time[index]);
if (tmpM == null) {
List<Integer[]> list = new ArrayList<>();
list.add(new Integer[]{index, 2});
map.put(30 + time[index], list);
}else{
tmpM.add(new Integer[]{index, 2});
}
index++;
} else {
time[index]++;
int tmp = index + 1;
while (tmp < time.length &;&; time[tmp] <= time[index]) {
time[tmp] = time[index];
tmp++;
}
}
}
}
int[] b = {100 - a[0], 80 - a[1], 60 - a[2]};
System.out.println(b[0] + " " + b[1] + " " + b[2]);
}
}
查看原帖
1 1
相关推荐
牛客热帖
更多
正在热议
更多
# 我的实习日记 #
4132934次浏览 33127人参与
# 你认为小厂实习有用吗? #
151375次浏览 789人参与
# 第3届现代汽车Code Faster急速编程挑战赛 #
7009次浏览 316人参与
# 为了找工作你投递了多少公司? #
118509次浏览 755人参与
# 机械人的offer怎么选 #
296112次浏览 1285人参与
# 实习生的生存小技巧 #
41543次浏览 357人参与
# 实习返校后,你的精神状态是__? #
47084次浏览 166人参与
# 你最近因为什么迷茫? #
106247次浏览 975人参与
# 我的租房踩坑经历 #
229196次浏览 1271人参与
# 通信硬件薪资爆料 #
1349038次浏览 7307人参与
# 牛友的春节生活 #
133959次浏览 838人参与
# 如果能重来,就业or读研你选哪个? #
331798次浏览 2843人参与
# 工作不开心辞职是唯一出路吗 #
20637次浏览 63人参与
# 牛客AI体验站 #
32913次浏览 447人参与
# 为什么国企只招应届生 #
271661次浏览 1346人参与
# 顺丰求职进展汇总 #
91498次浏览 372人参与
# 你觉得什么岗位会被AI替代 #
68537次浏览 401人参与
# 机械人求职现状 #
45480次浏览 335人参与
# 求职遇到的搞笑事件 #
208647次浏览 1078人参与
# 你觉得机械有必要实习吗 #
92076次浏览 543人参与
# 体制内上岸心路历程 #
42101次浏览 243人参与
华为HUAWEI公司氛围 750人发布