单调栈
zyq_20030305
der
展开
-
poj3250翻译+题解(单调栈)
#include<stdio.h> int a[80005],f[80005]; int main() { int n,i,j,top=1; long long ans=0; scanf("%d",&n); for(i=1;i<=n;i++) scanf("%d",&a[i]); f[1]=a[1]; for(i=2;i<=n;i++) { if(f[top]>a[i]) f[++top]=a[i],ans+=top-1; else { while(f[top]<=原创 2017-08-13 22:21:37 · 321 阅读 · 0 评论 -
USACO 2009 Mar Silver 3.Look Up
Description Farmer John's N (1 1..N, are once again standing in a row. Cow i has height H_i (1 H_i Each cow is looking to her left toward those with higher index numbers. We say that cow i原创 2017-11-17 23:10:01 · 206 阅读 · 0 评论