Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

连排序都没用完全是线性的,为啥还是47ms T.T

Posted by zhouyunothing at 2013-09-04 10:50:29 on Problem 3663
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator