#include<cstdio> #include<cstdio> #include<iostream> #include<cstring> using namespace std;int s[2000]; int n; int cnt=1; int ans; int main() { // freopen("cover.in","r",stdin); // freopen("cover.out","w",stdout); scanf( ans=n; int x,y; scanf( s[1]=y; for(int i=2;i<=n;i++) { scanf( while(cnt>0&&s[cnt]>y) cnt--; if(s[cnt]==y) ans--; s[++cnt]=y; } printf( }
Comments 1 条评论
博主 Vingying
辣鸡代码如上
AC代码如下
#include
#include
#include
#include
#include
#include
using namespace std;
int s[250005],t;
int cnt;
int n;
int main()
{
scanf("%d",&n);
int x;
int top=0;
for (int i=1;is[top]) s[++top]=t;
else
{
while (t<s[top])
s[top--]=0;
if (s[top]==t) cnt--;
else s[++top]=t;
}
}
printf("%d",cnt);
return 0;
}