Advertisement
Dang_Quan_10_Tin

CAU2 HSGHN L9 2015-2016

Dec 24th, 2021
935
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #define task "CAU2"
  2.  
  3. #include <iostream>
  4. #include <cstdio>
  5.  
  6. using namespace std;
  7.  
  8. using ll = long long;
  9. using ld = long double;
  10.  
  11. constexpr int N = 3e4 + 5;
  12. constexpr int Inf = 1e9 + 7;
  13.  
  14. int n, a[N], b[N];
  15.  
  16. void Read()
  17. {
  18.     cin >> n;
  19.  
  20.     for (int i = 1; i <= n; ++i)
  21.         cin >> a[i];
  22. }
  23.  
  24. void Solve()
  25. {
  26.     b[0] = -Inf;
  27.     for (int i = 1; i <= n; ++i)
  28.         b[i] = max(b[i - 1], a[i]);
  29.  
  30.     for (int i = 1; i <= n; ++i)
  31.         cout << b[i] << " ";
  32. }
  33.  
  34. int32_t main()
  35. {
  36.     ios::sync_with_stdio(0);
  37.     cin.tie(0);
  38.     cout.tie(0);
  39.     if (fopen(task ".INP", "r"))
  40.     {
  41.         freopen(task ".INP", "r", stdin);
  42.         freopen(task ".OUT", "w", stdout);
  43.     }
  44.  
  45.     Read();
  46.     Solve();
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement