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

#TimeUsernameProblemLanguageResultExecution timeMemory
44057LkvatashidzePaprike (COI18_paprike)C++11
100 / 100
190 ms21016 KiB
#include <bits/stdc++.h> using namespace std; void DFS(int,int); int a[100005], dp[100005]; int n, Q; vector < vector < int > > g; int cnt; int main() { cin >> n >> Q; g.resize(n+1); for (int k=1; k<=n; k++) cin >> a[k]; for (int k=1; k<n; k++) { int x, y; cin >> x >> y; g[x].push_back(y); g[y].push_back(x); } DFS(1,-1); cout << cnt; return 0; } void DFS (int v, int p) { dp[v]=a[v]; multiset < int > st; for (int k=0; k<g[v].size(); k++) { int to=g[v][k]; if (to==p) continue; DFS(to,v); st.insert(dp[to]); } while (!st.empty()) { int q=(*st.begin()); if (dp[v]+q<=Q) { dp[v]+=q; } else { cnt++; } st.erase(st.begin()); } }

Compilation message (stderr)

paprike.cpp: In function 'int main()':
paprike.cpp:17:6: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
      for (int k=1; k<=n; k++)
      ^~~
paprike.cpp:20:10: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
          for (int k=1; k<n; k++) {
          ^~~
paprike.cpp: In function 'void DFS(int, int)':
paprike.cpp:39:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
      for (int k=0; k<g[v].size(); k++) {
                    ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...