百度之星度度熊与邪恶大魔王
程序员文章站
2023-12-27 09:22:15
...
心酸心累 通不过
package me;
import java.util.Scanner;
public class Main {
static int[] k;
static int[] p;
static int min =100000;
static int juge = 0;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n =sc.nextInt();
int m=sc.nextInt();
int[] a =new int[n];
int[] b =new int[n];
k =new int[m];
p =new int[m];
for(int i=0;i<n;i++){
a[i]=sc.nextInt();
b[i]=sc.nextInt();
}
for(int j=0;j<m;j++){
k[j]=sc.nextInt();
p[j]=sc.nextInt();
}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
da(j,a[i],b[i],k[j]);
}
if(juge==-1){
System.out.println("-1");
}else{
System.out.println(min);
}
}
}
public static void da(int jineng,int a,int b,int o){
if(p[jineng]-b<=0){
juge =-1;
}
a = a-(p[jineng]-b);
if(a<=0){
if(min>o){
juge = 1;
min =o;
}
return;
}else if(juge!=-1){
da(1-1,a,b,o+k[0]);
da(2-1,a,b,o+k[1]);
}
}
}
推荐阅读