#include<bits/stdc++.h>
using namespace std;
using ll = long long;
vector<vector<ll>>gp;
void solve(){
ll n,m,k;
cin>>n>>m>>k;
gp = vector<vector<ll>>(n);
for(ll i = 1;i<n;i++){
ll u;
cin>>u;
--u;
// cout<<u<<endl;
gp[u].push_back(i);
gp[i].push_back(u);
}
ll ans= 0;
vector<pair<ll,ll>>a(n,{0,-1e9});
for(ll i = 0;i<m;i++){
ll u;
cin>>u;
cin>>a[u].first>>a[u].second;
ans+=a[u].second;
}
cout<<ans<<endl;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(nullptr);
// ll t;cin>>t;while(t--)
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
8184 KB |
Output is correct |
2 |
Correct |
20 ms |
8796 KB |
Output is correct |
3 |
Correct |
34 ms |
10768 KB |
Output is correct |
4 |
Correct |
29 ms |
10192 KB |
Output is correct |
5 |
Correct |
33 ms |
10992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
37 ms |
7924 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
1884 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |