Advertisement
Guest User

Untitled

a guest
May 18th, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int n;
  7.     cin >> n;
  8.     int apple[n];
  9.     for(int i = 0; i < n;i++)
  10.         cin >> apple[i];
  11.     for (int i=0; i< n-1; i++) {
  12.         int firstBox,secondBox;
  13.         cin>>firstBox>>secondBox;
  14.         apple[secondBox-1] += apple[firstBox -1];
  15.        
  16.     }
  17.     int k;
  18.     cin>>k;
  19.     for (int i = 0; i < k; i++) {
  20.         int x;
  21.         cin >>x;
  22.         cout<<apple[x-1]<<" ";
  23.     }
  24.    
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement