Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- int apple[n];
- for(int i = 0; i < n;i++)
- cin >> apple[i];
- for (int i=0; i< n-1; i++) {
- int firstBox,secondBox;
- cin>>firstBox>>secondBox;
- apple[secondBox-1] += apple[firstBox -1];
- }
- int k;
- cin>>k;
- for (int i = 0; i < k; i++) {
- int x;
- cin >>x;
- cout<<apple[x-1]<<" ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement