Fast input output in java its amazing zing zing
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger;
class Main {
static List<Integer>[] edges;
static boolean[] vis;
static List<Integer> path;
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
FastScanner in=new FastScanner();
PrintWriter out=new PrintWriter(System.out);
int t = in.nextInt();
while(t-->0)
{
int num = in.nextInt();
int[] arr1 = new int[num];
int[] arr2 = new int[num];
int[] w = new int[num];
for(int i=0; i<num; i++){
arr1[i] = in.nextInt();
}
for(int i=0; i<num; i++){
arr2[i] = in.nextInt();
w[i] = arr1[i]*arr2[i];
}
int max=w[0],index=0;
for(int i=1;i<num;i++)
{
if(w[i]>max)
{
max=w[i];
index=i;
}
if(w[i]==max && arr2[i]>arr2[index])
{
index=i;
}
}
out.println(index+1);
}
out.close();
}
static long gcd(long a, long b)
{
if(b==0)
return a;
else
return gcd(b, a%b);
}
static class FastScanner {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] readArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
}
}
Comments
Post a Comment