mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-10 06:38:48 +00:00
P1181 数列分段 Section I
R39919674
This commit is contained in:
parent
4b3ce2cea6
commit
0d963e43c2
20
problem/P1181/P1181.cpp
Normal file
20
problem/P1181/P1181.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user