fork(1) download
  1. vector <int> getOrdering( vector <int> height, vector <int> bloom, vector <int> wilt )
  2. {
  3. int n = height.size();
  4. vector <int> res (n);
  5. vector <int> mark (n, 0);
  6. int maxi, ind;
  7. bool b;
  8. for (int i = 0; i < n; i++)
  9. {
  10. ind = maxi = -1;
  11. for (int j = 0; j < n; j++)
  12. if (!mark[j])
  13. {
  14. b = true;
  15. for (int k = 0; k < n; k++)
  16. if (!mark[k] && height[k] < height[j] &&
  17. ( (bloom[k] >= bloom[j] && bloom[k] <= wilt[j]) || (bloom[j] >= bloom[k] && bloom[j] <= wilt[k]) )
  18. )
  19. {
  20. b = false;
  21. break;
  22. }
  23. if (b && height[j] > maxi)
  24. {
  25. maxi = height[j];
  26. ind = j;
  27. }
  28. }
  29. mark[ind] = 1;
  30. res[i] = maxi;
  31. }
  32. return res;
  33. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty