Advertisement
El_GEMMY

left max

Mar 26th, 2022
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.35 KB | None | 0 0
  1. // Those who cannot remember the past are
  2. // condemned to repeat it (use DP -_-)
  3. // - George Santayana
  4.  
  5. #include <bits/stdc++.h>
  6. #include <ext/pb_ds/assoc_container.hpp>
  7. #include <ext/pb_ds/tree_policy.hpp>
  8.  
  9. using namespace std;
  10. using namespace __gnu_pbds;
  11.  
  12. #define all(v) v.begin(),v.end()
  13. #define rall(v) v.rbegin(),v.rend()
  14. #define ll long long
  15. #define ull unsigned long long
  16. #define MOD 1000000007
  17. #define PI 3.14159265
  18. #define ceil(a, b) ((a / b) + (a % b ? 1 : 0))
  19. #define imin INT_MIN
  20. #define imax INT_MAX
  21. #define inf 2000000000
  22. #define nl '\n'
  23. #define modulo(a, b, mod) ((((a) % mod) * ((b) % mod)) % mod)
  24. #define debug(x) cout << "x: " << x << nl;
  25. #define debug2(x, y) cout << "x: " << x << " y: " << y << nl;
  26. #define ordered_set tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>
  27. #define ordered_map tree<int, int, less<>, rb_tree_tag, tree_order_statistics_node_update>
  28.  
  29. //vector<int> dx = {0, 0, 1, -1, 1, 1, -1, -1}, dy = {1, -1, 0, 0, 1, -1, 1, -1};
  30. //vector<int> dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};
  31.  
  32. template<typename T = int> istream& operator>>(istream& in, vector<pair<int, int>>& v){
  33.     for (auto& [x, y] : v) in >> x >> y;
  34.     return in;
  35. }
  36.  
  37. template<typename T = int> istream& operator>>(istream& in, vector<T>& v){
  38.     for (T& i : v) in >> i;
  39.     return in;
  40. }
  41.  
  42. template<typename T = int> ostream& operator<<(ostream& out, const vector<T>& v){
  43.     for (const T& x : v)
  44.         out << x << ' ';
  45.     return out;
  46. }
  47.  
  48. void Start_Crushing() {
  49.     ios_base::sync_with_stdio(false);
  50.     cin.tie(nullptr);
  51.     cout.tie(nullptr);
  52. #ifndef ONLINE_JUDGE
  53.     freopen("input.txt", "r", stdin);
  54.     freopen("output.txt", "w", stdout);
  55. #endif
  56. }
  57.  
  58. void print(int idx, vector<int>& v, int max_so_far){
  59.     if(idx == v.size())
  60.         return;
  61.  
  62.     int curr = max(v[idx], max_so_far);
  63.     cout << curr << ' ';
  64.  
  65.     print(idx + 1, v, curr);
  66. }
  67.  
  68. void solve(){
  69.     int n; cin >> n;
  70.     vector<int> v(n); cin >> v;
  71.  
  72.     print(0, v, imin);
  73. }
  74.  
  75. int main(){
  76.     Start_Crushing();
  77.  
  78.     int t = 1;
  79. //    /*Multiple test cases?*/ cin >> t;
  80.     while (t--) {
  81.         solve();
  82.         if(!t) break;
  83.         cout << nl;
  84.     }
  85.  
  86. //    for(int tc = 1; tc <= t; tc++){
  87. //        cout << "Case #" << tc << ": ";
  88. //        solve();
  89. //        if(tc != t)
  90. //            cout << nl;
  91. //    }
  92.  
  93.     return 0;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement