// ID:1281 TITLE:最大上升子序列 #include #include int main() { int length; std::cin >> length; std::vector v(length); std::vector> result; for (int i = 0; i < length; i++) { int input_element; std::cin >> input_element; v[i] = input_element; } { bool flag = true; int prev = 0; while (!v.empty()) { if (*v.rbegin() > prev) { prev = *v.rbegin(); v.pop_back(); result.end()->push_back(prev); } else { flag = false; result.push_back(std::vector()); } } } int max = 0, max_index = 0; for (int i = 0; i < result.size(); i++) { if (result[i].size() > max) { max_index = i; max = result[i].size(); } } for (auto v : result[max_index]) { std::cout << v << " "; } std::cout << std::endl; }