[继续找状态做简单题]HDU 1052 Tian Ji -- The Horse Racing

2014-11-24 08:48:34 · 作者: · 浏览: 0

继续找状态,慢慢恢复:点击打开链接

策略证明如下(声明:PPT为转载):

\

\

\

\

#include 
  
   
#include 
   
     #include 
    
      using namespace std; int tian[1001]; int qi[1001]; bool cmp(int a,int b) { return a>b; } int main() { int horse; while(cin>>horse) { int tianbest,tianworst,qibest,qiworst; int counter=0; if(horse==0) break; for(int i=0;i
     
      >tian[i]; for(int j=0;j
      
       >qi[j]; sort(tian,tian+horse,cmp); sort(qi,qi+horse,cmp); tianbest=0; qibest=0; tianworst=horse-1; qiworst=horse-1; int dui=0; while(dui++
       
        qi[qibest]) { counter+=200; tianbest++; qibest++; } else if(tian[tianbest]
        
         qi[qiworst]) { counter+=200; tianworst--; qiworst--; } else { if(tian[tianworst]