(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #240750

#TimeUsernameProblemLanguageResultExecution timeMemory
240750VEGAnnPaprike (COI18_paprike)C++14
100 / 100
111 ms19580 KiB
#include <bits/stdc++.h> #define PB push_back #define all(x) x.begin(),x.end() #define sz(x) ((int)x.size()) using namespace std; const int N = 100100; vector<int> g[N], vc[N]; int n, k, ans = 0, h[N]; void dfs(int v, int p){ for (int u : g[v]){ if (u == p) continue; dfs(u, v); vc[v].PB(h[u]); } sort(all(vc[v])); ans += sz(vc[v]); for (int vl : vc[v]){ if (h[v] + vl > k) break; h[v] += vl; ans--; } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); #ifdef _LOCAL freopen("in.txt","r",stdin); #endif // _LOCAL cin >> n >> k; for (int i = 0; i < n; i++) cin >> h[i]; for (int i = 1; i < n; i++){ int x, y; cin >> x >> y; x--; y--; g[x].PB(y); g[y].PB(x); } dfs(0, -1); cout << ans; 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...