解题思路:签到题。首先找出最少补充x[i]需要消耗掉多少瓶水。从而在得到摄入的最小值
import java.util.Scanner; import java.util.Collections; import java.util.ArrayList; import java.util.StringTokenizer; public class Main{ public static void main(String[]args) { Scanner input=new Scanner(System.in); ArrayList<Integer>list=new ArrayList<>(); ArrayList<Integer>temp=new ArrayList<>(); int n=input.nextInt(); while(n-->0) { int ans=0; int v=input.nextInt(); int g=input.nextInt(); while(v-->0) { int x=input.nextInt(); int y=input.nextInt(); if(g%x==0) { ans=(g/x)*y; list.add(ans); } else { ans=((g/x)+1)*y; list.add(ans); } } Collections.sort(list); temp.add(list.get(0)); } for(int i:temp) { System.out.println(i); } } }
标签:java,int,ans,list,初赛,nextInt,2020,input,程序设计 From: https://www.cnblogs.com/liliczw2209/p/17589698.html