-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1090.cpp
More file actions
34 lines (33 loc) · 689 Bytes
/
1090.cpp
File metadata and controls
34 lines (33 loc) · 689 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> tree;
double highest = -1.0, start, incre;
int n, cnt, root;
void dfs(int u, double price){
int size = tree[u].size();
if(size == 0){
if(price > highest){
highest = price;
cnt = 1;
}else if(price == highest) cnt++;
return;
}
for(int i=0; i<size; i++){
dfs(tree[u][i], price * incre);
}
}
int main(){
ios::sync_with_stdio(false);
cin>>n>>start>>incre;
incre = 1.0 + incre / 100.0;
tree.resize(n);
for(int i=0; i<n; i++){
int father;
cin>>father;
if(father == -1) root = i;
else tree[father].push_back(i);
}
dfs(root, start);
cout<<fixed<<setprecision(2)<<highest<<' '<<cnt;
return 0;
}