B.cpp 610 B

123456789101112131415161718192021222324
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main() {
  4. for (int n; cin >> n; ){
  5. vector < int > bombs(n);
  6. for (auto & b : bombs) {
  7. cin >> b;
  8. }
  9. vector < int > h(bombs.size(), 0);
  10. h[0] = 1;
  11. for (int i = 1; i < bombs.size(); i++) {
  12. int max = 0;
  13. for (int j = 0; j < i; j++) {
  14. if (bombs[j] >= bombs[i] && h[j] > max) {
  15. max = h[j];
  16. }
  17. h[i] = max + 1;;
  18. }
  19. }
  20. cout << * max_element(h.begin(), h.end()) << endl;
  21. }
  22. return 0;
  23. }