fork download
  1. #include <cstdio>
  2. #include <vector>
  3.  
  4. int main(){
  5.  
  6. long n; scanf("%ld", &n);
  7. std::vector<bool> a(n + 1);
  8.  
  9. long next = n;
  10. for(long p = 0; p < n; p++){
  11. long x; scanf("%ld", &x);
  12. a[x] = 1;
  13.  
  14. while(a[next] == 1){
  15. printf("%ld ", next);
  16. --next;
  17. }
  18.  
  19. puts("");
  20. }
  21.  
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 4556KB
stdin
100
98 52 63 2 18 96 31 58 84 40 41 45 66 100 46 71 26 48 81 20 73 91 68 76 13 93 17 29 64 95 79 21 55 75 19 85 54 51 89 78 15 87 43 59 36 1 90 35 65 56 62 28 86 5 82 49 3 99 33 9 92 32 74 69 27 22 77 16 44 94 34 6 57 70 23 12 61 25 8 11 67 47 83 88 10 14 30 7 97 60 42 37 24 38 53 50 4 80 72 39
stdout












100 











































99 98 






























97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 








80 79 78 77 76 75 74 73 
72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 
39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1