Pagini recente » Cod sursa (job #2723668) | Cod sursa (job #2722829) | Cod sursa (job #36904) | Cod sursa (job #2392881) | Cod sursa (job #1787131)
#include <fstream>
using namespace std;
ifstream f ("scmax.in");
ofstream g ("scmax.out");
long long N, kp, kq, j, a[100003], poz[100003], q[100003];
void put(long long x, long long i) {
long long st = 1, dr = kq, mij = 0;
while(st < dr) {
mij = (st + dr) / 2;
if(x > q[mij]) st = mij + 1;
else dr = mij - 1;
}
if(q[st] < x && q[st]) st++;
q[st] = x, kq = max(kq, (long long)st), poz[++kp] = kq;
}
int main()
{
f >> N;
for(long long i = 1; i <= N; i++) f >> a[i];
for(long long i = 1; i <= N; i++)
put(a[i], i);
g << kq << "\n";
j = 1;
for(int i = 1; i <= kq; i++)
g << q[i] << " ";
g << "\n";
return 0;
}