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 |
二分?!!!#include<stdio.h> int a[1000001]; int main() { long int l[20001],i,j,k,n,s,max=0,ans=0; memset(a,0,sizeof(a)); scanf("%d %d",&n,&s); for (i=1; i<=n; i++) { scanf("%d",&l[i]); a[l[i]]++; if (l[i]>max) max=l[i]; } for (i=1; i<=s; i++) a[i]+=a[i-1]; for (i=1; i<=n; i++) if (l[i]<s) { ans+=a[s-l[i]]; if (s-l[i]>=l[i]) ans--; } printf("%d",ans/2); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator