/**
* author: wxhtzdy
* created: 30.06.2022 09:53:47
**/
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<vector<int>> g(n);
for (int i = 0; i < n - 1; i++) {
int u, v;
cin >> u >> v;
--u; --v;
g[u].push_back(v);
g[v].push_back(u);
}
int ans = 0;
for (int i = 0; i < n; i++) {
int ptr = i;
long long s = 0;
while (ptr < n && s + a[ptr] <= k) {
s += a[ptr];
ptr += 1;
}
ans += (ptr < n);
i = ptr - 1;
}
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
8076 KB |
Output is correct |
2 |
Correct |
35 ms |
8128 KB |
Output is correct |
3 |
Correct |
33 ms |
8128 KB |
Output is correct |
4 |
Correct |
37 ms |
8112 KB |
Output is correct |
5 |
Correct |
34 ms |
8028 KB |
Output is correct |
6 |
Correct |
32 ms |
7988 KB |
Output is correct |
7 |
Correct |
34 ms |
8036 KB |
Output is correct |
8 |
Correct |
38 ms |
7596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |