Cod sursa(job #2068154)
Utilizator | Data | 17 noiembrie 2017 11:41:50 | |
---|---|---|---|
Problema | Subsir crescator maximal | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.58 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("sclm.in");
ofstream c("sclm.out");
int main()
{
int n,a[1000],S[1000],p[1000];
f>>n;
for(int i=1;i<=n;i++)
f>>a[i];
int k,maxx=0;
for(int i=1;i<n;i++){
p[0]=i;
k=0;
for(int j=i+1;j<=n;j++){
if(a[p[k]]<=a[j]){
p[k+1]=j;
k++;
}
}
if(k+1>maxx){
maxx=k+1;
for(int l=0;l<maxx;l++)
S[l]=p[l];}
}
for(int l=0;l<maxx;l++)
c<<S[l]<<" ";
return 0;
}