0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-30 20:56:29 +00:00
OI-codes/Luogu/P1181/P1181.cpp

20 lines
330 B
C++
Raw Normal View History

2020-10-16 13:23:45 +00:00
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, sum = 0, ans = 1, t;
cin >> n >> m;
for (int i = 0; i < n; i++) {
cin >> t;
if (sum + t > m) {
ans++;
sum = t;
2021-11-19 09:01:13 +00:00
} else {
2020-10-16 13:23:45 +00:00
sum += t;
}
}
cout << ans << endl;
return 0;
}