提交时间:2023-11-02 18:34:36

运行 ID: 29710

#include<cstdio> #include<cmath> #include<cstring> #include<algorithm> using namespace std; int main() { int a[105],i,j,m,n,ans = 0; scanf("%d %d",&n,&m); for(i = 1;i <= m;i++) { scanf("%d",&a[i]); } for(i = 1;i <= m;i++) { n = n - a[i]; if(n < 0) { n = n + a[i]; ans = ans + 1; } } printf("%d",ans); return 0; }