Pagini recente » Cod sursa (job #3270987) | Cod sursa (job #2990866) | Cod sursa (job #1999074) | Arhiva de probleme | Cod sursa (job #858487)
Cod sursa(job #858487)
#include <fstream>
using namespace std;
ifstream f("scmax.in");
ofstream g("scmax.out");
long N, a, v[100001],poz[100001], pmax=0;
int main(){
int nrmax;
f>>N;
for (int i=1;i<=N;++i) f>>v[i];
for (int i=N;i>0;--i){
if (v[i]<nrmax) { ++pmax; nrmax=v[i]; }
poz[pmax]=nrmax;
}
g<<pmax<<'\n';
for (int i=pmax;i>0;--i){
g<<poz[i];
if (i!=1) g<<' ';
}
g<<'\n';
g.close();
return 0;
}