CCF|分蛋糕|Java

import java.util.Scanner;

public class tyt
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int k = in.nextInt();
int count = 0;
int a = 0, b = 0;
for (int i = 0; i < n; i++)
{
if (b < k && i != n - 1)
{
b += in.nextInt();
}
if (b >= k || i == n - 1)
{
a++;
b = 0;
}
}
System.out.println(a);

}

}

posted @ 2018-09-13 19:12  默语柯  阅读(363)  评论(0编辑  收藏  举报