Cod sursa(job #2748837)
| Utilizator | Data | 3 mai 2021 16:52:30 | |
|---|---|---|---|
| Problema | Subsir crescator maximal | Scor | 65 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.55 kb |
#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;
ifstream fin("scmax.in");
ofstream fout("scmax.out");
int main()
{
int n; fin >> n;
vector<int> ans;
while(n--) {
int x; fin >> x;
auto poz = lower_bound(ans.begin(), ans.end(), x);
if(poz == ans.end())
ans.push_back(x);
else
ans[poz - ans.begin()] = x;
}
fout << ans.size() << '\n';
for(int x: ans)
fout << x << ' ';
return 0;
}
