hdoj1050

Moving Tables

|code--------------------------------------------------------------------------------------------------+

|001| /***************************************************************\                              

|002|  *Author: 小呼                                                                               

|003|  *Created Time: Fri 09 Jul 2010 03:00:33 PM CST                                                

|004|  *File Name: b.cpp                                                                             

|005|  *Description:                                                                                 

|006| \***************************************************************/                              

|007| //*========================*Head File*========================*\\                              

|008|                                                                                                

|009| #include<iostream>                                                                             

|010| #include<stdio.h>                                                                              

|011| #include<stdlib.h>                                                                             

|012| #include<string.h>                                                                             

|013| /*----------------------*Global Variable*----------------------*/                              

|014|                                                                                                

|015| int T,N,s,t,times[200];                                                                        

|016| //*=======================*Main Program*=======================*//                             

|017| using namespace std;                                                                           

|018|                                                                                                

|019| int main(){                                                                                    

|020| .       scanf("%d",&T);                                                                        

|021| .       while(T--){                                                                            

|022| .       .       scanf("%d",&N);                                                                

|023| .       .       memset(times,0,sizeof(times));                                                 

|024| .       .       while(N--){                                                                    

|025| .       .       .       scanf("%d%d",&s,&t);                                                   

|026| .       .       .       s=(s-1)/2;                                                             

|027| .       .       .       t=(t-1)/2;                                                             

|028| .       .       .       if(s>t).       .       //当s>t时交换s,t的值                      

|029| .       .       .         s^=t^=s^=t;                                                          

|030| .       .       .       for(int i=s;i<=t;++i)                                                  

|031| .       .       .         times[i]++;                                                          

|032| .       .       }                                                                              

|033| .       .       int res=-1;                                                                    

|034| .       .       for(int i=0;i<200;++i)                                                         

|035| .       .         res=res<times[i]?times[i]:res;                                               

|036| .       .       printf("%d\n",res*10);                                                         

|037| .       }                                                                                      

|038| }                                                                                              

end+--------------------------------------------------------------------------------------------------+


你可能感兴趣的:(OJ)