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 |
16MS水过……#include"stdio.h" #include"algorithm" using namespace std; int main() { int n,s,t,i,j; int a[20002]; int count=0; scanf("%d%d",&n,&s); for(i=0;i<n;i++) scanf("%d",&a[i]); sort(a,a+n); j=n-1; for(i=0;i<n-1;i++) { if(a[i]>=s) break; while(a[i]+a[j]>s) j--; if(j<=i) break; count+=(j-i); } printf("%d\n",count); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator