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

#TimeUsernameProblemLanguageResultExecution timeMemory
238671KastandaPaprike (COI18_paprike)C++11
100 / 100
86 ms17656 KiB
// Criminal #include<bits/stdc++.h> using namespace std; const int N = 100005; int n, k, Cnt, A[N]; vector < int > Adj[N]; int DFS(int v, int p) { vector < int > V; for (int u : Adj[v]) if (u != p) V.push_back(DFS(u, v)); sort(V.begin(), V.end()); long long SM = A[v]; for (int a : V) SM += a; while (SM > k) SM -= V.back(), V.pop_back(), Cnt ++; return (SM); } int main() { scanf("%d%d", &n, &k); for (int i = 1; i <= n; i ++) scanf("%d", &A[i]); for (int i = 1; i < n; i ++) { int v, u; scanf("%d%d", &v, &u); Adj[v].push_back(u); Adj[u].push_back(v); } DFS(1, 0); return !printf("%d\n", Cnt); }

Compilation message (stderr)

paprike.cpp: In function 'int main()':
paprike.cpp:23: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:25:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &A[i]);
         ~~~~~^~~~~~~~~~~~~
paprike.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &v, &u);
         ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...