SHARE
TWEET

Untitled

a guest Apr 24th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define ll long long
  2.  
  3. vector<long> autumnLeaves(vector<int> leaves, int percentage, vector<int> day, vector<int> starting, vector<int> ending) {
  4.     vector <int> v = leaves;
  5.     int n = (int)v.size();
  6.     int p = percentage;
  7.     vector <int> d = day;
  8.     vector <int> l = starting, r = ending;
  9.     int q = (int)d.size();
  10.    
  11.     vector <long> res;
  12.    
  13.     for (int i = 0; i < q; i++) {
  14.         int lm = l[i];
  15.         int rm = r[i];
  16.         lm--;
  17.         rm--;
  18.         ll tot = 0;
  19.         for (int j = lm; j <= rm; j++) {
  20.             int x = leaves[j];
  21.             int ans = 0;
  22.             for (int k = 0; k < d[i]; k++) {
  23.                 int y = ((ll)x * p + 99) / 100;
  24.                 ans = y;
  25.                 if (ans == 0) {
  26.                     break;
  27.                 }
  28.                 x -= y;
  29.             }
  30.            
  31.             tot += ans;
  32.         }
  33.        
  34.         res.push_back(tot);
  35.     }
  36.  
  37.     return res;
  38. }
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