이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/******************************************************
| '_ \ / _` |/ __| '_ ` _ \ / _` | '_ \
| |_) | (_| | (__| | | | | | (_| | | | |
| .__/ \__,_|\___|_| |_| |_|\__,_|_| |_|
|_|
__| |____________________________________________
,--. ,--. ,--. ,--.
|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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |