关注
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
相关推荐
04-03 08:39
河南科技大学 Java 点赞 评论 收藏
分享
牛客热帖
更多
正在热议
更多
# 从投递到OC,你用了多久 #
2658次浏览 24人参与
# 总结:哪家公司最喜欢泡池子 #
168460次浏览 584人参与
# 厦门银行科技岗值不值得投 #
19151次浏览 423人参与
# 我的求职进度条 #
991414次浏览 6571人参与
# 实习教会我的事 #
73749次浏览 508人参与
# 父母问你工作找得怎么样,怎么回 #
346次浏览 21人参与
# 一人一道大厂面试题 #
127768次浏览 1314人参与
# 哪些公司一直卡在简历筛选 #
107268次浏览 371人参与
# 我想象的实习vs现实的实习 #
333112次浏览 2298人参与
# Agent面试会问什么? #
41229次浏览 1499人参与
# 拿到offer之后,可以做些什么 #
105509次浏览 512人参与
# 米哈游笔试 #
656608次浏览 1160人参与
# 一人分享一个skill #
10788次浏览 251人参与
# 春招至今,你收到几个面试了? #
117592次浏览 1424人参与
# 说说你知道的学历厂 #
402973次浏览 1441人参与
# bilibili求职进展汇总 #
192326次浏览 1095人参与
# 有深度的简历长什么样? #
54073次浏览 732人参与
# 上班以后,你还有哪些坚持的爱好? #
30361次浏览 303人参与
# 大厂无回复,继续等待还是奔赴小厂 #
350067次浏览 2006人参与
# 今年你最想重开的一场面试是? #
103892次浏览 357人参与
# 米哈游工作体验 #
30006次浏览 145人参与
