intbinary_search(int len, int i){ int first = 1, last = len; while(first < last){ int mid = first + (last - first) / 2; if (b[mid] >= a[i]) last = mid; else first = mid + 1; } return first; }
intmain(){ int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &a[i]); b[1] = a[0]; int len = 1; for (int i = 1; i < n; i++){ if (a[i] > b[len]){ b[++len] = a[i]; } else { int j = binary_search(len, i); b[j] = a[i]; } } printf("%d\n", len); return0; }
intmain(){ scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &a[i]); int res = 0; for (int i = 0; i < n; i++){ for (int j = 0; j < i; j++){ if (a[j] < a[i]) dp[i] = max(dp[i], dp[j] + 1); } res = max(dp[i], res); } printf("%d", res + 1); return0; }