fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int N_MAX_SIZE = 500000;
  5. const int M_MAX_SIZE = 100000;
  6.  
  7. int main() {
  8. int n, m, v[N_MAX_SIZE + 1];
  9. cin >> n;
  10. for (int i = 1; i <= n; ++i) {
  11. cin >> n;
  12. }
  13. cin >> m;
  14. int x = -1;
  15. for (int i = 1; i <= m; ++i) {
  16. if (x < v[i]) {
  17. x = v[i];
  18. }
  19. cout << x << " ";
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0s 5284KB
stdin
5
1 2 3 4 5
3
1 2 3
stdout
0 0