题目:
package cn.xaut;
import java.util.HashMap;
import java.util.Scanner;
public class T_three {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
//m天
int m = sc.nextInt();
//n个技能
int n = sc.nextInt();
int result[]=new int[n+1];
for(int i=0;i<n+1;i++){
result[i]=-1;
}
HashMap<Integer, Grow> growMap = new HashMap<>();
HashMap<Integer, Skill> skillMap = new HashMap<>();
for(int i=0;i<m;i++){
Grow grow = new Grow();
grow.setTL(sc.nextInt());
grow.setZL(sc.nextInt());
grow.setWL(sc.nextInt());
growMap.put((i+1),grow);
}
for(int i=0;i<n;i++){
Skill skill = new Skill();
skill.setTL(sc.nextInt());
skill.setZL(sc.nextInt());
skill.setWL(sc.nextInt());
skillMap.put((i+1),skill);
}
Grow growNow = new Grow();
growNow.setTL(0);
growNow.setZL(0);
growNow.setWL(0);
for(int i=1;i<=m;i++){
//第i天
Grow grow = growMap.get(i);
int tlPuls = grow.getTL();
int zlPuls = grow.getZL();
int wlPlus = grow.getWL();
int tl = growNow.getTL();
int zl = growNow.getZL();
int wl = growNow.getWL();
growNow.setTL(tl+tlPuls);
growNow.setZL(zl+zlPuls);
growNow.setWL(wl+wlPlus);
for(int j=1;j<=n;j++){
Skill skill = skillMap.get(j);
if(growNow.getTL()>=skill.getTL()&&growNow.getZL()>=skill.getZL()&&growNow.getWL()>=skill.getWL()){
if(result[j]==-1){
result[j]=i;
}
}
}
}
for(int i=1;i<=n;i++){
System.out.print(result[i]+"\t");
}
}
}
class Grow{
private int TL;
private int ZL;
private int WL;
public int getTL() {
return TL;
}
public void setTL(int TL) {
this.TL = TL;
}
public int getZL() {
return ZL;
}
public void setZL(int ZL) {
this.ZL = ZL;
}
public int getWL() {
return WL;
}
public void setWL(int WL) {
this.WL = WL;
}
}
class Skill{
private int TL;
private int ZL;
private int WL;
public int getTL() {
return TL;
}
public void setTL(int TL) {
this.TL = TL;
}
public int getZL() {
return ZL;
}
public void setZL(int ZL) {
this.ZL = ZL;
}
public int getWL() {
return WL;
}
public void setWL(int WL) {
this.WL = WL;
}
}
你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,技术专家团超时未为您做出解答
本次提问扣除的有问必答次数,将会以问答VIP体验卡(1次有问必答机会、商城购买实体图书享受95折优惠)的形式为您补发到账户。
因为有问必答VIP体验卡有效期仅有1天,您在需要使用的时候【私信】联系我,我会为您补发。