답안 #128077

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
128077 2019-07-10T11:53:54 Z faustaadp Chase (CEOI17_chase) C++17
20 / 100
4000 ms 14932 KB
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,k,i,a[101010],ta,tb,x[101010],has;
vector<ll> v[101010];
void dfs(ll aa,ll bb,ll cc,ll dd)
{
	ll tam=x[aa]-a[bb];	
	has=max(has,cc);
	ll ii;
	for(ii=0;ii<v[aa].size();ii++)
	{
		if(v[aa][ii]==bb)continue;
		if(dd)
			dfs(v[aa][ii],aa,cc+tam,dd-1);
		dfs(v[aa][ii],aa,cc,dd);
	}
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>k;
	for(i=1;i<=n;i++)
		cin>>a[i];
	for(i=1;i<n;i++)
	{
		cin>>ta>>tb;
		v[ta].pb(tb);
		v[tb].pb(ta);
		x[ta]+=a[tb];
		x[tb]+=a[ta];
	}
	for(i=1;i<=n;i++)
		dfs(i,0,0,k);
	cout<<has<<"\n";
}

Compilation message

chase.cpp: In function 'void dfs(ll, ll, ll, ll)':
chase.cpp:15:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(ii=0;ii<v[aa].size();ii++)
           ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2808 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2808 KB Output is correct
6 Correct 4 ms 2680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2808 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2808 KB Output is correct
6 Correct 4 ms 2680 KB Output is correct
7 Execution timed out 4091 ms 2808 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4010 ms 14932 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2808 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2808 KB Output is correct
6 Correct 4 ms 2680 KB Output is correct
7 Execution timed out 4091 ms 2808 KB Time limit exceeded
8 Halted 0 ms 0 KB -