标签:des style blog color os io strong for
hdu 4908 Bestcoder
#include"iostream" #include"cstdio" #include"cstring" #include"algorithm" using namespace std; const int ms=40000; int sum[ms+1],a[ms+20000]; int n,m; void solve() { memset(sum,0,sizeof(sum)); memset(a,0,sizeof(a)); int x,i,ans=0,id; for(i=1;i<=n;i++) { scanf("%d",&x); sum[i]=sum[i-1]; if(x==m) { id=i; continue; } if(x>m) sum[i]++; else sum[i]--; } for(i=0;i<id;i++) { a[sum[i]+ms]++; } for(i=id;i<=n;i++) ans+=a[sum[i]+ms]; printf("%d\n",ans); return ; } int main() { while(scanf("%d%d",&n,&m)==2) { solve(); } return 0; }
BestCoder Sequence,布布扣,bubuko.com
标签:des style blog color os io strong for
原文地址:http://www.cnblogs.com/767355675hutaishi/p/3905154.html