using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ int tot = 0; for(int i=0;i 1){ int c = (r + l) / 2; int v = Knap(c); if(v < V0){ l = c; } else { r = c; } } int min = r; if(Knap(l) == V0) min = l; l = 1; r = tot+1; while(r - l > 1){ int c = (r + l) / 2; int v = Knap(c); if(v <= V0){ l = c; } else { r = c; } } int max = l; Console.WriteLine(min); Console.WriteLine(max == tot ? "inf" : max.ToString()); } int Knap(int weight){ int[] dp = new int[weight+1]; for(int i=1;i<=weight;i++) dp[i] = -1; dp[0] = 0; for(int i=0;i=0;j--){ if(dp[j] == -1 || j + W[i] > weight) continue; dp[j + W[i]] = Math.Max(dp[j + W[i]], dp[j] + V[i]); } } int ret = 0; for(int i=0;i<=weight;i++) ret = Math.Max(ret,dp[i]); return ret; } int N; int[] V,W; int V0; public Sol(){ N = ri(); V = new int[N]; W = new int[N]; for(int i=0;iint.Parse(e));} static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));} static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));} }