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

Re:貌似要线性的算法才可以过吧

Posted by yujiashan at 2007-07-23 10:16:28 on Problem 3250
In Reply To:哪位高手麻烦帮忙看看^_^,怎么会超时呢?谢谢哦~ Posted by:acm_pku at 2007-07-23 09:47:20
> #include "stdio.h"
> int main()
> {
> int n,i,j;
> unsigned int sum=0;
> scanf("%d",&n);
> int *a=new int[n+1];
> int *b=new int[n+1];
> for(i=1;i<=n;i++)
> scanf("%d",&a[i]);
> for(i=1;i<=n;i++)
> {
> b[i]=0;
> for(j=i+1;j<=n;j++)
>   if(a[i]>a[j])
>     b[i]++;
>   else
>     break;
> }
> for(i=1;i<=n;i++)
>    sum=sum+b[i];
> printf("%u\n",sum);
> 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