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

#TimeUsernameProblemLanguageResultExecution timeMemory
91497MilkiPaprike (COI18_paprike)C++14
100 / 100
84 ms43932 KiB
#include<bits/stdc++.h> using namespace std; #define FOR(i, a, b) for(int i = a; i < b; ++i) #define REP(i, n) FOR(i, 0, n) #define _ << " " << #define sz(x) ((int) x.size()) #define pb(x) push_back(x) typedef long long ll; typedef pair<int, int> point; const int MAXN = 1e5 + 5; int n, k, cost[MAXN], sol; vector <int> E[MAXN]; void dfs(int x, int p = -1){ vector <int> tmp; for(auto e : E[x]){ if(e == p) continue; dfs(e, x); tmp.pb(cost[e]); } sort(tmp.begin(), tmp.end()); for(auto it : tmp) if(cost[x] + it > k) sol ++; else cost[x] += it; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> k; REP(i, n) cin >> cost[i]; REP(i, n - 1){ int a, b; cin >> a >> b; a --; b --; E[a].pb(b); E[b].pb(a); } dfs(0); cout << sol << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...