Submission #742964

# Submission time Handle Problem Language Result Execution time Memory
742964 2023-05-17T07:01:38 Z zaneyu Cat Exercise (JOI23_ho_t4) C++14
31 / 100
2000 ms 24740 KB
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pii=pair<int,int>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()),c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll maxn=5e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const int MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-4;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
int cur;
vector<int> g[maxn];
int ans=0;
int dp[maxn];
vector<pii> v;
int arr[maxn];
int pp;
int mx=0;
void dfs(int u,int p,int d){
	if(arr[u]>cur) return;
	if(pp==-1 or arr[u]>arr[pp]) pp=u,mx=dp[u]+d;
	for(int x:g[u]){
		if(x==p) continue;
		dfs(x,u,d+1);
	}
}

int main(){
	int n;
	cin>>n;
	
	REP(i,n){
		int x;
		cin>>x;
		--x;
		v.pb({x,i});
		arr[i]=x;
	}
	REP(i,n-1){
		int a,b;
		cin>>a>>b;
		--a,--b;
		g[a].pb(b),g[b].pb(a);
	}
	sort(ALL(v));
	for(auto x:v){
		cur=x.f;
		for(int a:g[x.s]){
			pp=-1;
			dfs(a,x.s,1);
			if(pp!=-1) MXTO(dp[x.s],mx);
		}
		//cout<<dp[x.s]<<' ';
	}
	cout<<dp[v.back().s];
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 12176 KB Output is correct
2 Correct 9 ms 12064 KB Output is correct
3 Correct 6 ms 12064 KB Output is correct
4 Correct 6 ms 12060 KB Output is correct
5 Correct 7 ms 12008 KB Output is correct
6 Correct 7 ms 11988 KB Output is correct
7 Correct 7 ms 12068 KB Output is correct
8 Correct 7 ms 12020 KB Output is correct
9 Correct 7 ms 12068 KB Output is correct
10 Correct 7 ms 11988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 12176 KB Output is correct
2 Correct 9 ms 12064 KB Output is correct
3 Correct 6 ms 12064 KB Output is correct
4 Correct 6 ms 12060 KB Output is correct
5 Correct 7 ms 12008 KB Output is correct
6 Correct 7 ms 11988 KB Output is correct
7 Correct 7 ms 12068 KB Output is correct
8 Correct 7 ms 12020 KB Output is correct
9 Correct 7 ms 12068 KB Output is correct
10 Correct 7 ms 11988 KB Output is correct
11 Correct 7 ms 12068 KB Output is correct
12 Correct 7 ms 11988 KB Output is correct
13 Correct 7 ms 11988 KB Output is correct
14 Correct 7 ms 12060 KB Output is correct
15 Correct 9 ms 11988 KB Output is correct
16 Correct 7 ms 11988 KB Output is correct
17 Correct 8 ms 11988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 12176 KB Output is correct
2 Correct 9 ms 12064 KB Output is correct
3 Correct 6 ms 12064 KB Output is correct
4 Correct 6 ms 12060 KB Output is correct
5 Correct 7 ms 12008 KB Output is correct
6 Correct 7 ms 11988 KB Output is correct
7 Correct 7 ms 12068 KB Output is correct
8 Correct 7 ms 12020 KB Output is correct
9 Correct 7 ms 12068 KB Output is correct
10 Correct 7 ms 11988 KB Output is correct
11 Correct 7 ms 12068 KB Output is correct
12 Correct 7 ms 11988 KB Output is correct
13 Correct 7 ms 11988 KB Output is correct
14 Correct 7 ms 12060 KB Output is correct
15 Correct 9 ms 11988 KB Output is correct
16 Correct 7 ms 11988 KB Output is correct
17 Correct 8 ms 11988 KB Output is correct
18 Correct 99 ms 12472 KB Output is correct
19 Correct 104 ms 12616 KB Output is correct
20 Correct 91 ms 12532 KB Output is correct
21 Correct 11 ms 12520 KB Output is correct
22 Correct 12 ms 12456 KB Output is correct
23 Correct 12 ms 12460 KB Output is correct
24 Correct 11 ms 12488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 12176 KB Output is correct
2 Correct 9 ms 12064 KB Output is correct
3 Correct 6 ms 12064 KB Output is correct
4 Correct 6 ms 12060 KB Output is correct
5 Correct 7 ms 12008 KB Output is correct
6 Correct 7 ms 11988 KB Output is correct
7 Correct 7 ms 12068 KB Output is correct
8 Correct 7 ms 12020 KB Output is correct
9 Correct 7 ms 12068 KB Output is correct
10 Correct 7 ms 11988 KB Output is correct
11 Correct 7 ms 12068 KB Output is correct
12 Correct 7 ms 11988 KB Output is correct
13 Correct 7 ms 11988 KB Output is correct
14 Correct 7 ms 12060 KB Output is correct
15 Correct 9 ms 11988 KB Output is correct
16 Correct 7 ms 11988 KB Output is correct
17 Correct 8 ms 11988 KB Output is correct
18 Correct 99 ms 12472 KB Output is correct
19 Correct 104 ms 12616 KB Output is correct
20 Correct 91 ms 12532 KB Output is correct
21 Correct 11 ms 12520 KB Output is correct
22 Correct 12 ms 12456 KB Output is correct
23 Correct 12 ms 12460 KB Output is correct
24 Correct 11 ms 12488 KB Output is correct
25 Correct 7 ms 11988 KB Output is correct
26 Correct 105 ms 12508 KB Output is correct
27 Correct 107 ms 12448 KB Output is correct
28 Correct 106 ms 12528 KB Output is correct
29 Correct 104 ms 12492 KB Output is correct
30 Correct 18 ms 12328 KB Output is correct
31 Correct 24 ms 12372 KB Output is correct
32 Correct 21 ms 12248 KB Output is correct
33 Correct 23 ms 12340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 12176 KB Output is correct
2 Correct 9 ms 12064 KB Output is correct
3 Correct 6 ms 12064 KB Output is correct
4 Correct 6 ms 12060 KB Output is correct
5 Correct 7 ms 12008 KB Output is correct
6 Correct 7 ms 11988 KB Output is correct
7 Correct 7 ms 12068 KB Output is correct
8 Correct 7 ms 12020 KB Output is correct
9 Correct 7 ms 12068 KB Output is correct
10 Correct 7 ms 11988 KB Output is correct
11 Correct 7 ms 12068 KB Output is correct
12 Correct 7 ms 11988 KB Output is correct
13 Correct 7 ms 11988 KB Output is correct
14 Correct 7 ms 12060 KB Output is correct
15 Correct 9 ms 11988 KB Output is correct
16 Correct 7 ms 11988 KB Output is correct
17 Correct 8 ms 11988 KB Output is correct
18 Correct 99 ms 12472 KB Output is correct
19 Correct 104 ms 12616 KB Output is correct
20 Correct 91 ms 12532 KB Output is correct
21 Correct 11 ms 12520 KB Output is correct
22 Correct 12 ms 12456 KB Output is correct
23 Correct 12 ms 12460 KB Output is correct
24 Correct 11 ms 12488 KB Output is correct
25 Execution timed out 2077 ms 24740 KB Time limit exceeded
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 11988 KB Output is correct
2 Correct 7 ms 11988 KB Output is correct
3 Execution timed out 2060 ms 24064 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 12176 KB Output is correct
2 Correct 9 ms 12064 KB Output is correct
3 Correct 6 ms 12064 KB Output is correct
4 Correct 6 ms 12060 KB Output is correct
5 Correct 7 ms 12008 KB Output is correct
6 Correct 7 ms 11988 KB Output is correct
7 Correct 7 ms 12068 KB Output is correct
8 Correct 7 ms 12020 KB Output is correct
9 Correct 7 ms 12068 KB Output is correct
10 Correct 7 ms 11988 KB Output is correct
11 Correct 7 ms 12068 KB Output is correct
12 Correct 7 ms 11988 KB Output is correct
13 Correct 7 ms 11988 KB Output is correct
14 Correct 7 ms 12060 KB Output is correct
15 Correct 9 ms 11988 KB Output is correct
16 Correct 7 ms 11988 KB Output is correct
17 Correct 8 ms 11988 KB Output is correct
18 Correct 99 ms 12472 KB Output is correct
19 Correct 104 ms 12616 KB Output is correct
20 Correct 91 ms 12532 KB Output is correct
21 Correct 11 ms 12520 KB Output is correct
22 Correct 12 ms 12456 KB Output is correct
23 Correct 12 ms 12460 KB Output is correct
24 Correct 11 ms 12488 KB Output is correct
25 Correct 7 ms 11988 KB Output is correct
26 Correct 105 ms 12508 KB Output is correct
27 Correct 107 ms 12448 KB Output is correct
28 Correct 106 ms 12528 KB Output is correct
29 Correct 104 ms 12492 KB Output is correct
30 Correct 18 ms 12328 KB Output is correct
31 Correct 24 ms 12372 KB Output is correct
32 Correct 21 ms 12248 KB Output is correct
33 Correct 23 ms 12340 KB Output is correct
34 Execution timed out 2077 ms 24740 KB Time limit exceeded
35 Halted 0 ms 0 KB -