Mai intai trebuie sa te autentifici.
Cod sursa(job #175019)
| Utilizator | Data | 9 aprilie 2008 15:02:38 | |
|---|---|---|---|
| Problema | Subsir crescator maximal | Scor | 65 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.53 kb |
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void) {
ifstream fin("scmax.in");
ofstream fout("scmax.out");
int N, i, t;
vector <int> sol;
vector <int> :: iterator it;
fin >> N;
for (i = 0; i < N; ++i) {
fin >> t;
it = lower_bound(sol.begin(), sol.end(), t);
if (it == sol.end())
sol.push_back(t);
else
*it = t;
}
fout << sol.size() << '\n';
for (it = sol.begin(); it != sol.end(); ++it)
fout << *it << ' ';
fout << '\n';
fin.close();
fout.close();
return 0;
}
