CHRL4 - Editorial

This is not a beginner level question in anyway. Do you expect a beginner to use a priority queue or segment tree in any way? Also DP can’t be a beginner level concept, however easy to implement it is, it’s still tough for beginners.

can you explain why log is used ?? any resources that can explain product is converted to sum in the given probelm not able to get it??my approach is exactly same as yours only difference is I multiplied and u used LOG??

I did it quite similar to you and am getting AC in just Task number 6. Were you able to solve it further?

Please let me know what is the issue with the below solution
/* package codechef; // don’t place package name! */

import java.util.;
import java.lang.
;
import java.io.*;

/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here

/*	BufferedReader in= new BufferedReader(new InputStreamReader(System.in));
	int n=Integer.parseInt(in.readLine());
	int k=Integer.parseInt(in.readLine()); */
	Scanner in =new Scanner(System.in);
	int n = in.nextInt();
	int k = in.nextInt();
	int mod=1000000007;
	
	int []a1 =new int[n];
	int []a2=new int[k];
	for(int i=0;i<n;i++)
	{
	    a1[i]=in.nextInt();  //1 2 3 4
	    
	}
	
	for(int i=0;i<k;i++)
	{
	    a2[i]=1;
	    //1 2 3 4
	    int x=i;
	    if(x!=0)
	    {
	        a2[x]=a1[0];
	    }
	    for(int j=i;j<n-1;j+=k)
	    {
	    a2[i]=(a1[j]*a2[i])%mod;
	    }
	    a2[i]=(a1[n-1]*a2[i])%mod;
	    
	}
	
int	min=a2[0];
	for(int j=1;j<k;j++)
	    {
	    if(a2[j]<min)
	    min=a2[j];
	    }
	
	System.out.println(min);
	
	
	
	
}

}

i am also facing same problem..

@anton_lunyov ,

Notice the following line in the question:

you can move from the X-th street to the Y-th street if and only if 1 <= Y - X <= K, where K is the integer value that is given to you.

This means X + 1 <= Y and Y <= X + K . This doesn’t hold true for the input selected by you. (In your input you also need to fix the value of K . That is a minor issue but worth mentioning anyways.)

yed