Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- ifstream cin("input.txt");
- int s, n;
- cin>>s>>n;
- int rc = 1, curs = 0;
- for(int i = 0; i < n; i++)
- {
- int cur;
- cin>>cur;
- if (curs + cur > s)
- {
- rc++;
- curs = 0;
- }
- curs += cur;
- }
- cout<<rc;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement