比赛 |
20120302 |
评测结果 |
AWWWWWWWWW |
题目名称 |
田忌赛马 |
最终得分 |
10 |
用户昵称 |
苏轼 |
运行时间 |
0.000 s |
代码语言 |
C++ |
内存使用 |
0.00 MiB |
提交时间 |
2012-03-02 21:26:21 |
显示代码纯文本
- #include<iostream>
- #include<cstdio>
- #include<cstdlib>
- using namespace std;
- int n;
- int q[5100],w[5100];
- int answer=0;
- int cmp ( const void *a , const void *b )
- {
- return *(int *)a - *(int *)b;
- }
- int main()
- {
- freopen ("horsea.in","r",stdin);
- freopen ("horsea.out","w",stdout);
- cin>>n;
- for (int i=0;i<n;i++)
- {
- cin>>q[i];
- }
- for (int i=0;i<n;i++)
- {
- cin>>w[i];
- }
- qsort(q,n,sizeof(q[0]),cmp);
- qsort(w,n,sizeof(w[0]),cmp);
- for (int i=n-1;i>=0;i--)
- {
- if (q[i]>w[i])
- {
- answer--;
- for (int j=0;j<n-1;j++)
- {
- w[j]=w[j+1];
- }
- }
- if (q[i]<w[i])
- {
- answer++;
- }
- if (q[i]==w[i])
- {
- answer--;
- if (q[i]==w[0])
- answer++;
- for (int j=0;j<n-1;j++)
- {
- w[j]=w[j+1];
- }
- }
- }
- cout<<answer;
- return 0;
- }