#include <iostream>
#include <vector>
using namespace std;
int debug = 1;
struct Entry {
int position;
int value;
Entry(int _position, int _value) : position(_position), value(_value) {}
};
int longest_increasing(const vector<int>& v, int from, int to) {
int count = 1;
int prev = v[from];
for (int i = from + 1; i < to; i++) {
if (v[i] > prev) {
prev = v[i];
count++;
}
}
return count;
}
int main()
{
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
int n;
int value;
cin >> n;
vector<int> necklace(n);
vector<Entry*> amazing;
// Read sizes
for (int i = 0; i < n; i++) {
cin >> value;
necklace[i] = value;
}
// Calculate initial amazing
/*amazing.push_back(new Entry(0, necklace[0]));
int prev = necklace[0];
for (int i = 1; i < n; i++) {
if (necklace[i] > prev) {
amazing.push_back(new Entry(i, necklace[i]));
prev = necklace[i];
}
}*/
int max_value = 0;
for (int i = 0; i < n; i++) {
int result = longest_increasing(necklace, i, n);
if (result > max_value) {
max_value = result;
}
}
if (debug) {
for (Entry* entry : amazing) {
cout << entry->position << " " << entry->value << endl;
}
}
cout << max_value << endl;
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | #include <iostream> #include <vector> using namespace std; int debug = 1; struct Entry { int position; int value; Entry(int _position, int _value) : position(_position), value(_value) {} }; int longest_increasing(const vector<int>& v, int from, int to) { int count = 1; int prev = v[from]; for (int i = from + 1; i < to; i++) { if (v[i] > prev) { prev = v[i]; count++; } } return count; } int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); int n; int value; cin >> n; vector<int> necklace(n); vector<Entry*> amazing; // Read sizes for (int i = 0; i < n; i++) { cin >> value; necklace[i] = value; } // Calculate initial amazing /*amazing.push_back(new Entry(0, necklace[0])); int prev = necklace[0]; for (int i = 1; i < n; i++) { if (necklace[i] > prev) { amazing.push_back(new Entry(i, necklace[i])); prev = necklace[i]; } }*/ int max_value = 0; for (int i = 0; i < n; i++) { int result = longest_increasing(necklace, i, n); if (result > max_value) { max_value = result; } } if (debug) { for (Entry* entry : amazing) { cout << entry->position << " " << entry->value << endl; } } cout << max_value << endl; return 0; } |
English