0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-20 02:25:25 +00:00

P1181 数列分段 Section I

R39919674
This commit is contained in:
Baoshuo Ren 2020-10-16 21:23:45 +08:00 committed by Baoshuo Ren
parent 4b3ce2cea6
commit 0d963e43c2
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

20
problem/P1181/P1181.cpp Normal file
View File

@ -0,0 +1,20 @@
#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;
}
else {
sum += t;
}
}
cout << ans << endl;
return 0;
}