Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- ifstream fin("plopi.in");
- ofstream fout("plopi1.out");
- int n,v[1005],L[1005],lmax;
- void citire()
- {
- fin>>n;
- for(int i=1;i<=n;i++)
- fin>>v[i];
- }
- void plopi()
- {
- L[n]=1;
- for(int i=n-1;i>=1;i--)
- {
- L[i]=1;
- for(int j=i+1;j<=n;j++)
- if(v[i]>v[j]&&L[i]<L[j]+1)
- L[i]=L[j]+1;
- if(L[i]>lmax)
- lmax=L[i];
- }
- }
- int main()
- {
- citire();
- plopi();
- fout<<n-lmax;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement