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

#TimeUsernameProblemLanguageResultExecution timeMemory
210350emanIaicepsaPaprike (COI18_paprike)C++14
100 / 100
81 ms15484 KiB
#include<bits/stdc++.h> #define IOS ios::sync_with_stdio(0),cin.tie(0); #define ll long long #define int ll #define pii pair<int,int> #define pb push_back #define fi first #define se second #define all(n) (n).begin(),(n).end() using namespace std; ll val[100005]; vector<int> E[100005]; ll res[100005]; int ans = 0; ll n,k; void dfs(int x,int p){ res[x] = val[x]; vector<ll> tmp; for(auto i:E[x]){ if(i==p)continue; dfs(i,x); tmp.pb(res[i]); } sort(all(tmp)); for(auto i:tmp){ if(res[x]+i>k)ans++; else res[x]+=i; } } signed main(){ IOS; cin>>n>>k; for(int i=1;i<=n;i++){ cin>>val[i]; } for(int i=1,a,b;i<n;i++){ cin>>a>>b; E[a].pb(b); E[b].pb(a); } dfs(1,0); cout<<ans<<'\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...