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 |
超时,请问有什么可以减少时间的算法#include"iostream" using namespace std; #define max 100000 int main() { int a[max][2]; int i,n,k,sum,j,m; while(cin>>n&&n!=0) { for(i=1;i<=n;i++) cin>>a[i][0]>>a[i][1]; k=0;m=-1; for(i=1;i<=n;i++) { sum=0; for(j=1;j<=n;j++) if(j!=i) { if(a[i][0]>a[j][0]&&a[i][1]>a[j][1]) break; } if(j==n+1) sum++; for(j=1;j<=n;j++) if(j!=i) { if(a[i][1]>a[j][1]&&a[i][0]>a[j][0]) break; } if(j==n+1) sum++; } cout<<sum<<endl; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator