题目
示例1:
输入
3
5
1 2 3 4 5
输出
6
示例2:
输入
4
5
5 4 1 1 1
输出
5
题解
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int len = in.nextInt();
int[] nums = new int[len];
for (int i = 0; i < len; i++) {
nums[i] = in.nextInt();
}
int res = 0;
int more = 0;
for (int i = 0; i < len; i++) {
more = nums[i] + more > n ? more + nums[i] - n : 0;
res++;
}
while (more > 0) {
more = more - n;
res++;
}
System.out.println(res);
}
}
https://blog.csdn.net/weixin_52908342/article/details/135351882