Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <iostream>
  2. #define DIM_MAX 1000
  3. using namespace std;
  4. struct cub
  5. {
  6. int l,nr;
  7. };
  8. cub st[DIM_MAX];
  9. int vf,n,x;
  10. int main()
  11. {
  12. cin>>n;
  13. vf=-1;
  14. for(int i=1;i<=n;i++)
  15. {
  16. cin>>x;
  17. if(vf==-1)
  18. {
  19. vf++;
  20. st[vf].l=x;
  21. st[vf].nr=i;
  22. }
  23. else
  24. {
  25. while(vf!=-1 && st[vf].l<x)
  26. vf--;
  27. vf++;
  28. st[vf].l=x;
  29. st[vf].nr=i;
  30.  
  31. }
  32.  
  33.  
  34. }
  35. cout<<vf+1<<endl;
  36. for(int i=0;i<=vf;i++)
  37. cout<<st[i].nr<<" ";
  38.  
  39.  
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement