using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; using System.Threading; using System.Runtime.CompilerServices; using System.Diagnostics; //using nint=System.Int32; static class Program{ const int mod=(int)1e9+7; static void Main(){ Sc sc=new Sc(); var (n,m,p)=sc.Tp3(); var a=sc.Ia; var h=new int[n][]; var bo=false; int f=0,g=0; for(int i = 0;im){bo=true;} f=Max(f,a[i]); g=Max(h[i][0],g); } if(g<=1){ Console.WriteLine(bo?1:-1); return; } h=h.OrderByDescending(x=>x[0]).ThenBy(x=>x[1]).ToArray(); var li=new List<(int,int)>(); for(int i = 0,j=h[0][1];i1){li.Add((h[i][0],h[i][1]));} } var pq=new Rheap(32); pq.Push(new Rheap.Dt(0,1)); var hs=new HashSet(); while(true){ var e=pq.Dequeue; if(e.d*f>m){ Console.WriteLine(e.n+1); return; } if(hs.Contains(e.d)){continue;} else{hs.Add(e.d);} for(int i = 0;i.Dt(e.n+li[i].Item2,li[i].Item1*e.d)); } } } } public class Rheap{ public class Dt{ public long n; public T d; public Dt(long n,T d){this.n=n;this.d=d;} public override string ToString()=>"d:"+d.ToString()+" n:"+n.ToString(); } private const int m=65; private long la=0; private Dt[][] bf; private int[] h; public int cnt=0; public Rheap(int max){ bf=new Dt[m][]; h=new int[m]; for(int i = 0;i0){ int p=0; for(int j = 1;jbf[i][j].n){p=j;} } la=bf[i][p].n; for(int j = 0;j(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(){var s=Console.ReadLine().Split();return (Ct(s[0]),Ct(s[1]));} public (T,T,T) Tp3(){var s=Console.ReadLine().Split();return (Ct(s[0]),Ct(s[1]),Ct(s[2]));} private T Ct(string s){return (T)Convert.ChangeType(s,typeof(T));} }