BZOJ 1113 [Poi2008]海报PLA 单调栈

题意:链接略方法:单调栈。解析:好久之前做的了,不过貌似是个单调栈水题?以前的码风比现在都不忍直视。代码:#include <stdio.h>int a[1000010] ;int z[1000010] ;int top ;int main(){int n ;scanf(“%d” , &n) ;for(int i = 1 ; i <= n ; i++){int useless ;scanf(“%d%d” , &useless , &a[i]) ;}int cnt = 0 ;a[0] = 0 ;for(int i = 1 ; i <= n+1 ; i++){while(a[i] < z[top] && top > 0){cnt ++ ;top — ;}while(a[i] == z[top] && top > 0){top — ;}z[++top] = a[i] ;}printf(“%d\n” , cnt) ;}

,没有什么可留恋,只有抑制不住的梦想,

BZOJ 1113 [Poi2008]海报PLA 单调栈

相关文章:

你感兴趣的文章:

标签云: