(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.

제출 #44054

#제출 시각아이디문제언어결과실행 시간메모리
44054LkvatashidzePaprike (COI18_paprike)C++11
100 / 100
111 ms32568 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() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 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()); } }

컴파일 시 표준 에러 (stderr) 메시지

paprike.cpp: In function 'int main()':
paprike.cpp:22:6: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
      for (int k=1; k<=n; k++)
      ^~~
paprike.cpp:25: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:44: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...