bzoj4282 慎二的随机数列
分析
这个博客和我做法差不多,嘤嘤嘤
代码
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
const int inf = 0x3f3f3f3f;
int dp[100100],a[100100],cnt,sum;
inline int go(){
int i,j,k,Ans=0;
memset(dp,0x3f,sizeof(dp));
for(i=1;i<=cnt;i++){
k=lower_bound(dp+1,dp+cnt+1,a[i])-dp;
Ans=max(Ans,k);
dp[k]=a[i];
}
return Ans;
}
int main(){
int n,m,i,j,k;
scanf("%d",&n);
for(i=1;i<=n;i++){
char s[10];
scanf("%s",s);
if(s[0]=='N')sum++;
else scanf("%d",&a[++cnt]),a[cnt]-=sum;
}
printf("%d",go()+sum);
return 0;
}