解题思路:
注意事项:
参考代码:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNext()) {
int m = scanner.nextInt();
int n = scanner.nextInt();
int[] arr = new int[n];
int num = 0;
for(int i=0;i<n;i++){
arr[i] = scanner.nextInt();
m -= arr[i];
if(m>=0){
num+=1;
}
else{
m +=arr[i];
continue;
}
}
System.out.println(n-num);
}
}
}
0.0分
0 人评分