Advertisement
yejolga

ol_4_13

Nov 3rd, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     ifstream cin("input.txt");
  9.  
  10.     int s, n;
  11.     cin>>s>>n;
  12.  
  13.     int rc = 1, curs = 0;
  14.     for(int i = 0; i < n; i++)
  15.     {
  16.         int cur;
  17.         cin>>cur;
  18.         if (curs + cur > s)
  19.         {
  20.             rc++;
  21.             curs = 0;
  22.         }
  23.         curs += cur;
  24.     }
  25.     cout<<rc;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement