Pagini recente » Cod sursa (job #2956635) | Cod sursa (job #1223159) | Cod sursa (job #912156) | Cod sursa (job #834989) | Cod sursa (job #654563)
Cod sursa(job #654563)
#include <fstream>
#include <algorithm>
using namespace std;
ifstream f("scmax.in");
ofstream g("scmax.out");
struct two {
int x,y;
} v[1030];
int a[300],n,i,poz,l;
int cmp ( two a, two b )
{
if (a.x==b.x) return a.y<b.y;
return a.x < b.x;
}
int main()
{
f>>n;
for(i=1; i<=n; i++) {
f>>v[i].x;
v[i].y=i;
}
sort(v+1,v+n+1,cmp);
for(i=1; i<=n; i++)
if (v[i].y>poz) {
poz=v[i].y;
l++;
}
g<<l<<'\n';
return 0;
}