Submission #586370

#TimeUsernameProblemLanguageResultExecution timeMemory
586370MilosMilutinovicPaprike (COI18_paprike)C++14
13 / 100
38 ms8128 KiB
/** * 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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...