import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution
{
public static void main(String[] args)
{
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int max=sc.nextInt();
int totalproblem[]=new int[n];
for(int i=0;i<n;i++)
totalproblem[i]=sc.nextInt();
int special=0;int page=1;
for(int chapter=0;chapter<n;chapter++)
{
if(chapter!=0)
page++;
int problem=1;
int k=1;
inner: while(problem<=totalproblem[chapter]&&k<=max)
{
if(problem==page)
{
special++;
problem++;
k++;
}
else
{
problem++;
k++;
}
if(problem<=totalproblem[chapter]&&k>max)
{
page++;
k=1;
continue inner;
}
}
}
System.out.println(special);
}
}
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution
{
public static void main(String[] args)
{
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int max=sc.nextInt();
int totalproblem[]=new int[n];
for(int i=0;i<n;i++)
totalproblem[i]=sc.nextInt();
int special=0;int page=1;
for(int chapter=0;chapter<n;chapter++)
{
if(chapter!=0)
page++;
int problem=1;
int k=1;
inner: while(problem<=totalproblem[chapter]&&k<=max)
{
if(problem==page)
{
special++;
problem++;
k++;
}
else
{
problem++;
k++;
}
if(problem<=totalproblem[chapter]&&k>max)
{
page++;
k=1;
continue inner;
}
}
}
System.out.println(special);
}
}
No comments:
Post a Comment