Cod sursa(job #935127)

Utilizator whoasdas dasdas who Data 1 aprilie 2013 19:37:44
Problema Subsir crescator maximal Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.82 kb
/*
ID: i.adri1
PROG: scmax
LANG: C++
*/

#include <iostream>
#include <fstream>
#include <assert.h>
#include <math.h>
#include <string.h>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

#define NMAX 100001
#define inf 0x7fffffff

int main()
{
    ifstream in("scmax.in");
    ofstream out("scmax.out");
    int v[NMAX], sol[NMAX];
    int n, lmax = 0, x, i;
    in>>n;
    while(n-->0) {
        cin>>x;
        for(i = 0; i < lmax && x > v[i]; i++);
        v[i] = x;
        if (i > lmax) {
            lmax = i + 1;
            memcpy(sol, v, lmax * sizeof(int));
        }
    }
    out<<lmax<<endl;
    for (int i = 0; i < lmax; i++)
        out<<sol[i]<<" ";
    return 0;
}