알고리즘
백준 1817번 짐 챙기는 숌 C++
영춘권의달인
2022. 5. 6. 15:59
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
using namespace std;
using ll = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, m;
cin >> n >> m;
int cnt = 0;
int weight = m;
for (int i = 0; i < n; i++) {
int book;
cin >> book;
if (weight + book > m) {
cnt++;
weight = book;
}
else {
weight += book;
}
}
cout << cnt;
};