Submission #1348871

#TimeUsernameProblemLanguageResultExecution timeMemory
1348871ramzialoulouFinancial Report (JOI21_financial)C++20
5 / 100
33 ms2632 KiB
#include <bits/stdc++.h>
 
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, d;
  cin >> n >> d;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> best(n + 1, INT_MAX);
  best[0] = 0;
  int ans = 0;
  for (int x : a) {
    int low = 1, high = n;
    while (low <= high) {
      int mid = (low + high) >> 1;
      if (best[mid] >= x) {
        high = mid - 1;
      } else {
        low = mid + 1;
      }
    }
    best[low] = min(best[low], x);
    ans = max(ans, low);
  }
  cout << ans << '\n';
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...