This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, s = 0, ans = 0;
cin >> n >> k;
vector<int> h(n);
vector<pair<int, int>> e(n - 1);
for (int &s : h) {
cin >> s;
}
for (auto &[a, b] : e) {
cin >> a >> b;
a--;
b--;
}
for (int i = 0; i < n; i++) {
s += h[i];
if (s > k) {
ans++;
s = h[i];
}
}
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |