比赛 |
20120302 |
评测结果 |
AWWWTTTTTT |
题目名称 |
田忌赛马 |
最终得分 |
10 |
用户昵称 |
日光。 |
运行时间 |
0.000 s |
代码语言 |
C++ |
内存使用 |
0.00 MiB |
提交时间 |
2012-03-02 21:53:05 |
显示代码纯文本
- #include<fstream>
- using namespace std;
- int N,i,j,m,k,win=0,lose=0,ans;
- int a[5001],b[5001];//a田忌b齐王
- int search(int length)
- {
- if(length==0)
- {
- ans=win-lose;
- }
- else
- {
- for(i=1;i<=length;i++)
- {
- for(j=1;j<length;j++)
- {
- if(a[i]>a[j])
- {
- m=a[i];
- a[i]=a[j];
- a[j]=m;
- }
- }
- }
- for(i=1;i<=length;i++)
- {
- for(j=1;j<=length;j++)
- {
- if(b[i]>b[j])
- {
- k=b[i];
- b[i]=b[j];
- b[j]=k;
- }
- }
- }
- if(a[1]>=b[1])
- {
- win++;
- for(i=2;i<=length;i++)
- {
- a[0];
- b[0];
- search(length-1);
- }
- }
- if(a[1]==b[1])
- {
- for(i=2;i<=length;i++)
- {
- a[1]=0;
- b[1]=0;
- search(length-1);
- }
- }
- if(a[1]<b[1])
- {
- lose++;
- for(i=2;i<=length;i++)
- {
- a[length]=0;
- b[1]=0;
- search(length-1);
- }
- }
- }
- }
- int main()
- {
- ifstream fin("horsea.in");
- ofstream fout("horsea.out");
- fin>>N;
- for(i=1;i<=N;i++)
- {
- fin>>b[i];
- }
- for(i=1;i<=N;i++)
- {
- fin>>a[i];
- }
- search(N);
- fout<<ans<<endl;
- return 0;
- }