[NOIP-2011-D1B]选择客栈-听说是二分或单调队列

发布于 2017-08-18  11 次阅读



if(p2.color==p1.color),ans++。

#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
struct s
{
	int a,b,c;
}s[2000005];
int main()
{
	int n,k,p;
	int ans=0;
	int tmp=0;
	scanf(
	for(int i=1;i<=n;i++)
	{
		int co,h;
		scanf(
		if(h<=p) tmp=i;
		if(tmp>=s[co].a) s[co].c=s[co].b;
		s[co].a=i;
		ans+=s[co].c;
		s[co].b++;
	}
	printf(
}