熬夜果然效率低,无端贡献两罚WA。。。
典型LIS
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn= 1005;
int a[maxn], dp[maxn];
int main(int argc, char const *argv[])
{
int n, m= 1;
scanf("%d", &n);
for (int i= 1; i<= n; ++i){
scanf("%d", a+i);
}
for (int i= 1; i<= n; ++i){
dp[i]= 1;
}
for (int i= 2; i<= n; ++i){
int &x= dp[i];
for (int j= i-1; j> 0; --j){
if (a[j]< a[i]){
x= max(x, dp[j]+1);
}
}
m= max(m, x);
}
cout<<m;
return 0;
}