Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int n, i, vf, lu;
  5. struct da
  6. {
  7. int l, p;
  8. }v[1001];
  9. int main()
  10. {
  11. cin>>n;
  12. for(i=1; i<=n; i++)
  13. {
  14. cin>>lu;
  15. if(vf==0 || lu<=v[vf].l)
  16. {
  17. v[++vf].p=i;
  18. v[vf].l=lu;
  19. }
  20. else
  21. {
  22. while(lu>v[vf].l && vf!=0)
  23. vf--;
  24. v[++vf].p=i;
  25. v[vf].l=lu;
  26.  
  27. }
  28. }
  29. cout<<vf<<'\n';
  30. for(i=1; i<=vf; i++)
  31. cout<<v[i].p<<' ';
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement