uva 1344
2014-01-25 16:00
281 查看
这本来是暑假集训做过的一个题 现在做来
就三种情况
1.田忌最快的比齐王最快的快 就用最快的比最快的
2.田忌最慢的比齐王最慢的快 就用最慢的比最慢的
3.上两种情况都不符合 用田忌最慢的去比齐王最快的
就三种情况
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 1344
- UVa 1344 - Tian Ji -- The Horse Racing
- UVa 1344 - Tian Ji -- The Horse Racing(贪心)
- POJ2287/UVA1344 Tian Ji -- The Horse Racing
- uva 1344 - Tian Ji -- The Horse Racing(贪心)
- UVA 1344 / UVALive 3266 / POJ 2287 / HDU 1052 Tian Ji -- The Horse Racing
- UVA 1344 - Tian Ji -- The Horse Racing(贪心)
- UVa 1344 - Tian Ji -- The Horse Racing
- uva 1344 Tian Ji -- The Horse Racing
- UVA 1344 - Tian Ji -- The Horse Racing(很好的贪心题)
- uva1344 - Tian Ji -- The Horse Racing 田忌赛马
- UVA 1344 Tian Ji -- The Horse Racing
- 动态规划 UVA 1344 - Tian Ji -- The Horse Racing
- uva--1344--Tian Ji -- The Horse Racing
- UVa1344 - Tian Ji -- The Horse Racing
- UVa 1344 Tian Ji -- The Horse Racing 解题报告(贪心)
- UVA1344 - Tian Ji -- The Horse Racing
- UVA 1344 Tian Ji -- The Horse Racing(模拟)
- UVa 1556 1344
- UVA 1344 Tian Ji -- The Horse Racing