关注
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
相关推荐
点赞 评论 收藏
分享
牛客热帖
更多
正在热议
更多
# 我的求职总结 #
10992次浏览 198人参与
# 辞职之后最想做的一件事 #
7894次浏览 86人参与
# 毕业季,给职场新人一些建议 #
9613次浏览 187人参与
# 选offer应该考虑哪些因素 #
9147次浏览 128人参与
# 我的实习日记 #
2414772次浏览 25251人参与
# 工作后会跟朋友渐行渐远吗 #
20393次浏览 158人参与
# 你想留在一线还是回老家? #
36049次浏览 437人参与
# 你小时候最想从事什么职业 #
89942次浏览 1684人参与
# 设计人如何选offer #
107980次浏览 706人参与
# 毕业后不工作的日子里我在做什么 #
167584次浏览 1482人参与
# 生物制药/化工校招攻略 #
42605次浏览 282人参与
# 比亚迪求职进展汇总 #
703171次浏览 3058人参与
# 你们公司哪个部门最累? #
14140次浏览 118人参与
# 薪资爆料 #
101888次浏览 1038人参与
# 你们的毕业论文什么进度了 #
1013042次浏览 9505人参与
# 秋招想进国企该如何准备 #
56627次浏览 363人参与
# 招聘要求与实际实习内容不符怎么办 #
98125次浏览 717人参与
# 大学最后一个寒假,我想…… #
35396次浏览 454人参与
# 工作中的卑微时刻 #
8759次浏览 54人参与
# 第一份工作应该只看薪资吗 #
136775次浏览 1437人参与