Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n, k;
- cin >> n >> k;
- int niza[n];
- for(int i = 0; i < n; i++) {
- cin >> niza[i];
- }
- int zbir_na_lugje = 0;
- int gondoli = 1;
- for(int i = 0; i < n; i++) {
- if(zbir_na_lugje + niza[i] <= k) {
- zbir_na_lugje += niza[i];
- }
- else {
- zbir_na_lugje = niza[i];
- gondoli += 1;
- }
- }
- cout << gondoli << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement