Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int n, i, vf, lu;
- struct da
- {
- int l, p;
- }v[1001];
- int main()
- {
- cin>>n;
- for(i=1; i<=n; i++)
- {
- cin>>lu;
- if(vf==0 || lu<=v[vf].l)
- {
- v[++vf].p=i;
- v[vf].l=lu;
- }
- else
- {
- while(lu>v[vf].l && vf!=0)
- vf--;
- v[++vf].p=i;
- v[vf].l=lu;
- }
- }
- cout<<vf<<'\n';
- for(i=1; i<=vf; i++)
- cout<<v[i].p<<' ';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement