(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 #95354

#TimeUsernameProblemLanguageResultExecution timeMemory
95354dalgerokPaprike (COI18_paprike)C++14
100 / 100
71 ms17724 KiB
#include<bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, m, a[N], ans; vector < int > g[N]; void dfs(int v, int pr = -1){ vector < int > q; for(int to : g[v]){ if(to != pr){ dfs(to, v); q.push_back(a[to]); } } sort(q.begin(), q.end()); for(auto it : q){ if(a[v] + it > m){ ans += 1; } else{ a[v] += it; } } } int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n >> m; for(int i = 1; i <= n; i++){ cin >> a[i]; } for(int i = 1; i < n; i++){ int x, y; cin >> x >> y; g[x].push_back(y); g[y].push_back(x); } dfs(1); cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...