# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
128087 |
2019-07-10T12:03:11 Z |
faustaadp |
Chase (CEOI17_chase) |
C++17 |
|
1477 ms |
17788 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];
ll d[1010][110];
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);
}
}
ll depe(ll aa,ll bb,ll cc)
{
if(d[aa][bb]==-1)
{
d[aa][bb]=0;
ll ii;
for(ii=0;ii<v[aa].size();ii++)
{
if(v[aa][ii]==cc)continue;
d[aa][bb]=max(d[aa][bb],depe(v[aa][ii],bb,aa));
if(bb)
d[aa][bb]=max(d[aa][bb],depe(v[aa][ii],bb-1,aa)+x[aa]-a[cc]);
}
}
return d[aa][bb];
}
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++)
{
memset(d,-1,sizeof(d));
has=max(has,depe(i,k,0));
}
cout<<has<<"\n";
}
Compilation message
chase.cpp: In function 'void dfs(ll, ll, ll, ll)':
chase.cpp:16:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(ii=0;ii<v[aa].size();ii++)
~~^~~~~~~~~~~~~
chase.cpp: In function 'll depe(ll, ll, ll)':
chase.cpp:30:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(ii=0;ii<v[aa].size();ii++)
~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
3576 KB |
Output is correct |
2 |
Correct |
5 ms |
3548 KB |
Output is correct |
3 |
Correct |
5 ms |
3576 KB |
Output is correct |
4 |
Correct |
5 ms |
3576 KB |
Output is correct |
5 |
Correct |
7 ms |
3576 KB |
Output is correct |
6 |
Correct |
5 ms |
3576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
3576 KB |
Output is correct |
2 |
Correct |
5 ms |
3548 KB |
Output is correct |
3 |
Correct |
5 ms |
3576 KB |
Output is correct |
4 |
Correct |
5 ms |
3576 KB |
Output is correct |
5 |
Correct |
7 ms |
3576 KB |
Output is correct |
6 |
Correct |
5 ms |
3576 KB |
Output is correct |
7 |
Correct |
1477 ms |
3728 KB |
Output is correct |
8 |
Correct |
160 ms |
3740 KB |
Output is correct |
9 |
Correct |
82 ms |
3736 KB |
Output is correct |
10 |
Correct |
304 ms |
3832 KB |
Output is correct |
11 |
Correct |
305 ms |
3740 KB |
Output is correct |
12 |
Correct |
267 ms |
3704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
72 ms |
17788 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
3576 KB |
Output is correct |
2 |
Correct |
5 ms |
3548 KB |
Output is correct |
3 |
Correct |
5 ms |
3576 KB |
Output is correct |
4 |
Correct |
5 ms |
3576 KB |
Output is correct |
5 |
Correct |
7 ms |
3576 KB |
Output is correct |
6 |
Correct |
5 ms |
3576 KB |
Output is correct |
7 |
Correct |
1477 ms |
3728 KB |
Output is correct |
8 |
Correct |
160 ms |
3740 KB |
Output is correct |
9 |
Correct |
82 ms |
3736 KB |
Output is correct |
10 |
Correct |
304 ms |
3832 KB |
Output is correct |
11 |
Correct |
305 ms |
3740 KB |
Output is correct |
12 |
Correct |
267 ms |
3704 KB |
Output is correct |
13 |
Runtime error |
72 ms |
17788 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
14 |
Halted |
0 ms |
0 KB |
- |