import java.util.Scanner; public class test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int nClassCount = sc.nextInt(); int maxCount = sc.nextInt(); int []arr = new int[nClassCount]; for (int i = 0; i < nClassCount; i++) { arr[i] = sc.nextInt(); } int count = 1; int sum = 0; for (int i = 0; i < nClassCount; i++) { sum += arr[i]; if (sum <= maxCount) { continue; }else{ sum = arr[i]; count++; } } System.out.println(count); } }
点赞 2

相关推荐

点赞 评论 收藏
分享
点赞 评论 收藏
分享
点赞 评论 收藏
分享
牛客网
牛客企业服务