关注
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
相关推荐
2025-11-07 17:29
北京理工大学珠海学院 嵌入式软件工程师 点赞 评论 收藏
分享
牛客热帖
更多
- 1... 双非本秋招总结6702
- 2... 打工的这一年4476
- 3... 你会和mentor进行deeptalk吗?3168
- 4... 学院本 末 211 硕勇闯 java 后端实习美团 oc 逆袭指南3107
- 5... 牛客运营们,我保证这是我最后一次消费烤肠了!3004
- 6... 无语到一定地步是会笑的2839
- 7... 金丹后期牛友!我们新年再见2810
- 8... 没人带+同事冷漠,真的会内耗2780
- 9... 6块腹肌就是给自己最好的新年礼物!2515
- 10... 双非本2025秋招总结:65w+SSP三选一,最终还是“有鹅选鹅”|附面试心路历程2355
正在热议
更多
# 对2025年忏悔 #
4301次浏览 101人参与
# 你觉得专业和学校哪个对薪资影响最大 #
87469次浏览 587人参与
# 实习没人带,苟住还是跑路? #
12407次浏览 264人参与
# 巨人网络求职进展汇总 #
183818次浏览 1223人参与
# 元旦假期你打算怎么过 #
8005次浏览 172人参与
# 春招前还要继续实习吗? #
5018次浏览 63人参与
# 腾讯云智研发工作体验 #
34444次浏览 164人参与
# 面试官问过你最刁钻的问题是什么? #
9489次浏览 99人参与
# 大家实习都在做什么? #
8563次浏览 94人参与
# 一人说一家双休的公司 #
6980次浏览 93人参与
# 我们是不是被“优绩主义”绑架了? #
8989次浏览 284人参与
# 新年的第一句祝福 #
51030次浏览 376人参与
# 求职遇到的搞笑事件 #
154177次浏览 889人参与
# 妈妈治愈了你哪些脆皮时刻 #
38920次浏览 338人参与
# 腾讯工作体验 #
548773次浏览 3663人参与
# 我来点评面试官 #
38004次浏览 165人参与
# 设计人的面试记录 #
177695次浏览 1576人参与
# 机械人你觉得今年行情怎么样? #
6313次浏览 88人参与
# 牛客2025仙途报告 #
37623次浏览 488人参与
# 一起聊字节 #
238237次浏览 1014人参与
查看4道真题和解析

美的集团公司福利 819人发布