【继续找状态做简单题】HDU 1052 Tian Ji -- The Horse Racing
2014-02-09 15:16
295 查看
继续找状态,慢慢恢复:点击打开链接
策略证明如下(声明:PPT为转载):
![](http://img.blog.csdn.net/20131014131707125?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXpoMzU3OA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
![](http://img.blog.csdn.net/20131014131738265?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXpoMzU3OA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
![](http://img.blog.csdn.net/20131014131811609?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXpoMzU3OA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
![](http://img.blog.csdn.net/20131014131806031?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXpoMzU3OA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
策略证明如下(声明:PPT为转载):
#include <iostream> #include <algorithm> #include <cstring> 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<horse;i++) cin>>tian[i]; for(int j=0;j<horse;j++) cin>>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++<horse) { if(tian[tianbest]>qi[qibest]) { counter+=200; tianbest++; qibest++; } else if(tian[tianbest]<qi[qibest]) { counter-=200; tianworst--; qibest++; } else if(tian[tianbest]==qi[qibest]) { if(tian[tianworst]>qi[qiworst]) { counter+=200; tianworst--; qiworst--; } else { if(tian[tianworst]<qi[qibest]) { counter-=200; } tianworst--; qibest++; } } } cout<<counter<<endl; } return 0; }
相关文章推荐
- HDU-1052-Tian Ji -- The Horse Racing(C++ && 简单贪心)
- HDU - 1052 Tian Ji -- The Horse Racing(简单贪心)
- HDU 1052 Tian Ji -- The Horse Racing(贪心)
- HDU - 1052 Tian Ji -- The Horse Racing
- hdu 1052 Tian Ji -- The Horse Racing(贪心)
- hdu 1052 Tian Ji -- The Horse Racing
- HDU 1052 Tian Ji -- The Horse Racing
- HDU 1052:Tian Ji -- The Horse Racing【模拟】
- hdu 1052 Tian Ji -- The Horse Racing
- HDU 1052 - Tian Ji -- The Horse Racing(贪心)
- hdu 1052 Tian Ji -- The Horse Racing
- hdu-1052-Tian Ji -- The Horse Racing(经典)
- hdu 1052 Tian Ji -- The Horse Racing(贪心)
- hdu 1052(田忌赛马详解)Tian Ji -- The Horse Racing
- HDU-1052 Tian Ji -- The Horse Racing 贪心 考虑特殊位置(首尾元素)的讨论
- HDU 1052 Tian Ji -- The Horse Racing (贪心)
- HDU 1052 Tian Ji -- The Horse Racing
- HDU - 1052 Tian Ji -- The Horse Racing
- Hdu 1052 Tian Ji -- The Horse Racing
- hdu 1052 Tian Ji -- The Horse Racing(贪心)