제출 #1107591

#제출 시각아이디문제언어결과실행 시간메모리
1107591vjudge1Magic Tree (CEOI19_magictree)C++17
0 / 100
34 ms9988 KiB
/****************************************************** | '_ \ / _` |/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | (__| | | | | | (_| | | | | | .__/ \__,_|\___|_| |_| |_|\__,_|_| |_| |_| __| |____________________________________________ ,--. ,--. ,--. ,--. |oo | _ \ `. | oo | | oo| o o|~~ |(_) / ; | ~~ | | ~~|o o o o o |/\/\| '._,' |/\/\| |/\/\| __________________ ____________________________ ******************************************************/ #include <bits/stdc++.h> //#include "bigint.h" #define db(x) cerr << #x << ": " << x << endl #define print cerr << "Ah shit, here we go agian" << endl #define int long long int #define vii vector<int> #define pii pair<int ,int> #define vpi vector< pii > #define ff first #define ss second #define mp make_pair #define mod 1000000007 using namespace std; const int maxn = 1e5 + 100; vector<int> adj[maxn]; int w[maxn], d[maxn]; void solve(){ int n ,m ,k; cin >> n >> m >> k; for(int i = 2 ;i <= n; i++){ int x; cin >> x; adj[x].push_back(i); adj[i].push_back(x); } for(int i = 1 ;i <= m; i++){ int v; cin >> v; cin >> d[v] >> w[v]; } set<int> s; int tmp[k + 10] = {}; for(int i = 1; i <= n; i++){ if(adj[i].size() == 1){ tmp[d[i]] = max(tmp[d[i]], w[i]); } } int ans = 0; for(int i = 1 ;i <= k ;i++){ ans += tmp[i]; } cout << ans << endl; } signed main(){ ios_base::sync_with_stdio(0), cin.tie(0) ,cout.tie(0); //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); int t = 1; /// cin >> t; while(t--){ solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...