Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
连排序都没用完全是线性的,为啥还是47ms T.T#include<stdio.h> int a[1000001]={0}; int high[20000]; int main() { int m,n,i,j,b,s,H,L; scanf("%d%d",&n,&s); b=s/2; H=0; for(i=0;i<n;i++) { scanf("%d",&m); if(m<=b) a[m]++; else if(m<=s) high[H++]=m; } for(i=1;i<=b;i++) a[i]+=a[i-1]; j=((a[b]-1)*a[b])>>1; for(i=0;i<H;i++) j+=a[s-high[i]]; printf("%d\n",j); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator