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 |
这也wa啊!!郁闷#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator