Problem #1105 - ECNU Online Judge
#include<bits/stdc++.h>
using namespace std;
int distant[1026];
int main(){
int n,k;
cin>>n>>k;
int flag=1;
for(int i=1;i<=k+1;i++){
cin>>distant[i];
if(distant[i]>n){
cout<<"No Solution\n";
flag=0;
}
}
if(flag==1){
int ans=0,dis=0;
for(int i=1;i<=k+1;i++){
dis+=distant[i];
if(dis>n){
dis=distant[i];
ans++;
}
}
cout<<ans<<endl;
}
}