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

这也wa啊!!郁闷

Posted by birdo0o at 2008-04-14 23:12:37 on Problem 1089
#include<stdio.h>
int main() {
    int n;
    int left[50001],right[50001];
    int i,j,temp,begin,end;
    scanf("%d",&n);
    for (i=1;i<=n;i++) scanf("%d%d",&left[i],&right[i]);
    for (i=1;i<n;i++)
        for (j=i+1;j<=n;j++)
            if (left[i]>left[j]||(left[i]==left[j] && right[i]>right[j])) {
               temp=left[i];
               left[i]=left[j];
               left[j]=temp;
               
               temp=right[i];
               right[i]=right[j];
               right[j]=temp;
               }            
    begin=left[1];
    end=right[1];
    for (i=2;i<=n;i++){
        if (left[i]<=end) end=right[i];
        else {
             printf("%d %d\n",begin,end);
             begin=left[i];
             end=right[i];
             }
        }
    printf("%d %d\n",begin,end);     
    scanf("%d",&n);       
    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