You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
463 B
31 lines
463 B
#include<bits/stdc++.h>//万能头文件
|
|
|
|
using namespace std;
|
|
int a[100001] = {0};
|
|
|
|
int main() {
|
|
|
|
int m;
|
|
int n;
|
|
cin >> n >> m;
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
cin >> a[i];
|
|
}
|
|
|
|
int count = 0;
|
|
int sum = 0;
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
if (sum + a[i] > m) {
|
|
count++;
|
|
sum = 0;
|
|
}
|
|
sum += a[i];
|
|
}
|
|
if (sum) {
|
|
count++;
|
|
}
|
|
cout << count << endl;
|
|
return 0;
|
|
} |