标签:
输出一个整数,表示城市中最少包含的建筑物数量
#include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<algorithm> #include<set> using namespace std; int n,x,w,h[50005],ans,top,stack[50005]; int main() { scanf("%d%d",&n,&w); ans=n; for (int i=1;i<=n;i++) scanf("%d%d",&x,&h[i]); for (int i=1;i<=n;i++) { while (h[i]<stack[top]) top--; if (h[i]==stack[top]) ans--; else stack[++top]=h[i]; } printf("%d",ans); return 0; }
[Usaco2007 Demo][BZOJ1628] City skyline
标签:
原文地址:http://www.cnblogs.com/ws-fqk/p/4668063.html