Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #define DIM_MAX 1000
- using namespace std;
- struct cub
- {
- int l,nr;
- };
- cub st[DIM_MAX];
- int vf,n,x;
- int main()
- {
- cin>>n;
- vf=-1;
- for(int i=1;i<=n;i++)
- {
- cin>>x;
- if(vf==-1)
- {
- vf++;
- st[vf].l=x;
- st[vf].nr=i;
- }
- else
- {
- while(vf!=-1 && st[vf].l<x)
- vf--;
- vf++;
- st[vf].l=x;
- st[vf].nr=i;
- }
- }
- cout<<vf+1<<endl;
- for(int i=0;i<=vf;i++)
- cout<<st[i].nr<<" ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement