#include<iostream> #include<cstdio> #include<stack> using namespace std; int n,a,ans; stack<int> s; inline int read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x*=10;x+=ch-'0';ch=getchar();} return x*f; } int main(){ n=read(); for(int i=1;i<=n;i++){ a=read();a=read(); while(!s.empty()&&a<=s.top()){ if(a==s.top())ans++; s.pop(); } s.push(a); } printf("%d",n-ans); return 0; }
【上篇】bzoj1675 [Usaco2005 Feb]Rigging the Bovine Election 竞选划区
【下篇】1606: [Usaco2008 Dec]Hay For Sale 购买干草
【下篇】1606: [Usaco2008 Dec]Hay For Sale 购买干草