daily pastebin goal
30%
SHARE
TWEET

Untitled

a guest May 18th, 2015 205 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top