Skip to content

Commit

Permalink
Add 08731.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiyabye committed Feb 23, 2024
1 parent 4962b95 commit d82df62
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions 08xxx/08731.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <iostream>
#include <vector>
using namespace std;

void solve(void) {
int n, w; cin >> n >> w;
vector<int> a(n);
for (int i=0; i<n; i++) cin >> a[i];

int ans = 0, sum = 0;
for (int i=0; i<n; i++) {
sum += a[i];
if (sum >= w) {
ans++;
sum = 0;
}
}
cout << ans;
}

int main(void) {
ios::sync_with_stdio(false);
cin.tie(nullptr);

solve();
return 0;
}

0 comments on commit d82df62

Please sign in to comment.