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

读题很重要啊,这题垮了我好多天,附代码

Posted by xtu1014 at 2010-08-10 14:22:08 on Problem 2189
#include<iostream>
using namespace std;

int a[1001],n,p,c,x,i,ans,temp;

int main(){
    int count,j;
    scanf("%d%d%d",&n,&p,&c);
    for(i=1;i<=n;i++){
        scanf("%d",&x);
        a[x]++;
    }
    temp=0;
    ans=0;
    count=0;
    for(i=1;i<p;i++){
        temp=0;
        for(j=i;j<p;j++){
            temp+=a[j];
            if(c<temp){
                if(ans<j-i)
                    ans=j-i;
                break;    
            }
        }
        if(j==p&&ans<j-i)
            ans=j-i;
    }
    printf("%d\n",ans);
    system("pause");
    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