fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4. using namespace std;
  5.  
  6. int main() {
  7. int n, m, b[105], a;
  8. memset(b, 0, sizeof(b));
  9. scanf("%d%d", &n, &m);
  10. while(m--) {
  11. scanf("%d", &a);
  12. for(int i=a-1; i<n; i++) {
  13. if(b[i]==0) b[i]=a;
  14. else break;
  15. }
  16. }
  17. for(int i=0; i<n; i++) printf("%d ", b[i]);
  18. return 0;
  19. }
Success #stdin #stdout 0s 3344KB
stdin
5 5
5 4 3 2 1
stdout
1 2 3 4 5