标签:
Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 909 Accepted Submission(s): 346
#include<bits/stdc++.h> using namespace std; #define ll __int64 #define mod 1000000007 #define inf 999999999 #define pi 4*atan(1) //#pragma comment(linker, "/STACK:102400000,102400000") const int N=1e5+10,M=2*1e5+10; int a[N],b[N]; ll ans[N]; int l[M]; int r[M]; int main() { int x,y,z,i,t; int T; while(~scanf("%d",&x)) { memset(ans,0,sizeof(ans)); for(i=1;i<=x;i++) scanf("%d",&a[i]); for(i=1;i<=x;i++) { for(t=1;t<=x;t++) { if(a[t]==a[i]) b[t]=0; else b[t]=a[t]>a[i]?1:-1; } int flag=8000; for(t=i;t>0;t--) flag+=b[t],l[flag]++; flag=8000; for(t=i;t<=x;t++) flag-=b[t],r[flag]++; for(t=0;t<=16010;t++) ans[i]+=(ll)l[t]*r[t],l[t]=r[t]=0; } for(i=1;i<=x;i++) printf("%I64d%c",ans[i],(i==x)?‘\n‘:‘ ‘); } return 0; }
标签:
原文地址:http://www.cnblogs.com/jhz033/p/5539523.html