Submission #132152

#TimeUsernameProblemLanguageResultExecution timeMemory
132152VardanyanChase (CEOI17_chase)C++14
0 / 100
959 ms8632 KiB
#include <bits/stdc++.h> using namespace std; const int N = 100*1000+5; int d[N]; long long ans = 0; int qn; vector<int> g[N]; void dfs(int v,int p = -1,int hm = qn,long long now = 0){ if(hm == 0){ ans = max(ans,now); return; } for(int i = 0;i<g[v].size();i++){ int to = g[v][i]; if(to == p) continue; now+=d[to]; } for(int i = 0;i<g[v].size();i++){ int to = g[v][i]; if(to == p) continue; dfs(to,v,hm-1,now); } } int main(){ ios_base::sync_with_stdio(false); int n; cin>>n>>qn; for(int i = 1;i<=n;i++) cin>>d[i]; for(int i = 0;i<n-1;i++){ int x,y; cin>>x>>y; g[x].push_back(y); g[y].push_back(x); } for(int i = 1;i<=n;i++){ dfs(i); } cout<<ans<<endl; return 0; }

Compilation message (stderr)

chase.cpp: In function 'void dfs(int, int, int, long long int)':
chase.cpp:13:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<g[v].size();i++){
                   ~^~~~~~~~~~~~
chase.cpp:18:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<g[v].size();i++){
                   ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...