您的位置:首页 > 其它

uva 1344

2014-01-25 16:00 281 查看
这本来是暑假集训做过的一个题 现在做来

就三种情况

1.田忌最快的比齐王最快的快 就用最快的比最快的

2.田忌最慢的比齐王最慢的快 就用最慢的比最慢的

3.上两种情况都不符合 用田忌最慢的去比齐王最快的

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <string>
#include <cstring>
#include <algorithm>
#include <iostream>
#define maxn 110
#define INF 0x7fffffff
#define inf 10000000
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
using namespace std;

int a[1010], b[1010];

int main()
{
int n;
while(scanf("%d",&n) && n)
{
for(int i = 0 ; i < n; i++) scanf("%d",&a[i]);
for(int i = 0 ; i < n; i++) scanf("%d",&b[i]);
sort(a, a+n);
sort(b, b+n);
int tjmin = 0, tjmax = n-1, qwmin = 0, qwmax = n-1;
int sum = 0;
while(tjmin <= tjmax)
{
if(a[tjmax] > b[qwmax])
{
++ sum;
-- tjmax;
-- qwmax;
}
else if(a[tjmin] > b[qwmin])
{
++ sum;
++ tjmin;
++ qwmin;
}
else
{
if(a[tjmin] < b[qwmax]) -- sum;
-- qwmax;
++ tjmin;
}
}
printf("%d\n",sum*200);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  uva 贪心