Pagini recente » Cod sursa (job #198445) | Cod sursa (job #1506261) | Cod sursa (job #1508007) | Cod sursa (job #3275147) | Cod sursa (job #2909244)
#include<fstream>
#include<climits>
using namespace std;
ifstream cin("scmax.in");
ofstream cout("scmax.out");
#define maximumLength 100001
int n, maxLength=-1, currentLength=0, priorElement, currentElement, printElement[maximumLength], backElement[maximumLength];
int main() {
int i,j;
cin >> n;
cin >> currentElement;
backElement[currentLength] = currentElement;
currentLength++;
for (i = 1; i < n; i++) {
priorElement = currentElement;
cin >> currentElement;
if (priorElement == currentElement) {
continue;
}
else {
if (priorElement < currentElement) {
backElement[currentLength] = currentElement;
currentLength++;
}
else {
if (maxLength < currentLength) {
maxLength = currentLength;
for (j = 0; j < currentLength; j++) {
printElement[j] = backElement[j];
}
}
currentLength = 0;
backElement[currentLength] = currentElement;
currentLength++;
}
}
}
if (maxLength < currentLength) {
maxLength = currentLength;
for (j = 0; j < currentLength; j++) {
printElement[j] = backElement[j];
}
}
cout << maxLength << '\n';
for (i = 0; i < maxLength; i++) {
cout << printElement[i] << " ";
}
}