E.cpp 572 B

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