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

#TimeUsernameProblemLanguageResultExecution timeMemory
169466rzbtPaprike (COI18_paprike)C++14
100 / 100
121 ms23056 KiB
#include <cstdio> #include <algorithm> #include <vector> #define mp make_pair #define pb push_back #define F first #define S second #define all(x) x.begin(),x.end() #define MAXN 100005 typedef long long ll; using namespace std; int n,k,spice[MAXN]; int res=0; vector<int> deca[MAXN],niz[MAXN]; int dfs(int t,int o){ for(auto x:niz[t]){ if(x==o)continue; deca[t].pb(dfs(x,t)); } sort(all(deca[t])); int tz=spice[t]; for(auto x:deca[t]){ if(tz+x<=k)tz+=x; else res++; } return tz; } int main() { scanf("%d %d", &n, &k); for(int i=1;i<=n;i++) scanf("%d",spice+i); for(int i=1;i<n;i++){ int t1,t2; scanf("%d %d", &t1, &t2); niz[t1].pb(t2); niz[t2].pb(t1); } dfs(1,0); printf("%d",res); return 0; }

Compilation message (stderr)

paprike.cpp: In function 'int main()':
paprike.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &k);
     ~~~~~^~~~~~~~~~~~~~~~~
paprike.cpp:38:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",spice+i);
         ~~~~~^~~~~~~~~~~~~~
paprike.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &t1, &t2);
         ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...