We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
My solution is similar to yours but it is not able to pass the last test case... its giving wrong result for a few sets. Can you please help me understand what I did wrong.
importjava.io.*;importjava.util.*;importjava.text.*;importjava.math.*;importjava.util.regex.*;publicclassMain{publicstaticvoidmain(Stringargs[])throwsException{/* Enter your code here. Read input from STDIN. Print output to STDOUT */Scannersc=newScanner(System.in);intt=sc.nextInt();intn;intq1=0,q2=0,r1=0,r2=0;intsum=0;intlow;for(intai=0;ai<t;ai++){n=sc.nextInt();int[]a=newint[n];for(inti=0;i<n;i++){a[i]=sc.nextInt();}sum=0;intk=0;longsum1=1000000000;Arrays.sort(a);low=a[0];for(low=a[0];low>=0;low--){sum=0;for(inti=0;i<n;i++){k=a[i]-low;//System.out.println(low + " " + a[i]);q1=k/5;r1=k%5;q2=r1/2;r1=r1%2;sum=sum+r1+q2+q1;//System.out.println(a[i] + "---" + q1 + " " + q2 + " " + r1);}//System.out.println(sum + "");if(sum<sum1)sum1=sum;}System.out.println(sum1);}}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Equal
You are viewing a single comment's thread. Return to all comments →
My solution is similar to yours but it is not able to pass the last test case... its giving wrong result for a few sets. Can you please help me understand what I did wrong.