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 |
其实很简单的!把过道分成200份,定义一个整型数组统计每块过道上搬运经过的次数, 最后排序,输出最大的次数乘以10即可! 如果还不明白,看一下代码吧!A过的! #include<iostream> #include<algorithm> using namespace std; int main() { int n,num,a[200][2],b[200]; cin>>n; while(n--) {cin>>num; for(int m=0;m<200;m++) b[m]=0; for(int i=0;i<num;i++) {cin>>a[i][0]>>a[i][1]; if(a[i][0]>a[i][1]) {int temp=a[i][0];a[i][0]=a[i][1];a[i][1]=temp;} } for(int j=1;j<=200;j++) for(int k=0;k<num;k++) if((((a[k][0])<=2*j-1)&&((a[k][1])>=2*j-1)||(((a[k][0])<=2*j)&&((a[k][1])>=2*j)))) b[j-1]++; sort(&b[0],&b[200]); if(b[199]!=0) cout<<b[199]*10<<endl; else cout<<'10'<<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