1198 - Karate Competition
| Time Limit: 2 second(s) | Memory Limit: 32 MB |
Your karate club challenged another karate club in your town. Each club enters N players into the match, and each player plays one game against a player from the other team. Each game that is won is worth 2points, and each game that is drawn is worth 1 point. Your goal is to score as many points as possible.
Your secret agents have determined the skill of every member of the opposing team, and of course you know the skill of every member of your own team. You can use this information to decide which opposing player will play against each of your players in order to maximize your score. Assume that the player with the higher skill in a game will always win, and if the players have the same skill then they will draw.
You will be given the skills of your players and of the opposing players, you have to find the maximum number of points that your team can score.
Input
Input starts with an integer T (≤ 70), denoting the number of test cases.
Each case starts with a line containing an integer N (1 ≤ N ≤ 50). The next line contains N space separated integers denoting the skills of the players of your team. The next line also contains N space separated integers denoting the skills of the players of the opposite team. Each of the skills lies in the range [1, 1000].
Output
For each case, print the case number and the maximum number of points your team can score.
Sample Input |
Output for Sample Input |
|
4 2 4 7 6 2 2 6 2 4 7 3 5 10 1 5 10 1 4 10 7 1 4 15 3 8 7 |
Case 1: 4 Case 2: 2 Case 3: 4 Case 4: 5 |
1 #include<stdio.h>
2 #include<algorithm>
3 #include<iostream>
4 #include<string.h>
5 #include<stdlib.h>
6 #include<queue>
7 #include<set>
8 using namespace std;
9 int ans1[200];
10 int ans2[200];
11 bool flag[200];
12 bool flag1[200];
13 typedef struct pp
14 {
15 int x;
16 int id;
17 bool operator<(const pp &cx)const
18 {
19 return cx.x>x;
20 }
21 } ss;
22 int er(int n,int m,int ak,int ac[]);
23 int main(void)
24 {
25 int i,j,k;
26 scanf("%d",&k);
27 int s;
28 int n,m;
29 for(s=1; s<=k; s++)
30 {
31 scanf("%d",&n);
32 priority_queue<ss>que;
33 memset(flag,0,sizeof(flag));
34 memset(flag1,0,sizeof(flag1));
35 for(i=0; i<n; i++)
36 {
37 scanf("%d",&ans1[i]);
38 }
39 for(i=0; i<n; i++)
40 {
41 scanf("%d",&ans2[i]);
42 }
43 sort(ans1,ans1+n);
44 sort(ans2,ans2+n);
45 int sum=0;
46 int uu=0;
47 for(i=0;i<n;i++)
48 {
49 while(ans2[uu]<ans1[i]&&uu<n)
50 {
51 ss cc;
52 cc.id=uu;
53 cc.x=ans2[uu];
54 que.push(cc);
55 uu++;
56 }
57 if(!que.empty())
58 {
59 sum+=2;
60 ss ak=que.top();
61 que.pop();
62 flag[i]=true;
63 flag1[ak.id]=true;
64 }
65 } int ac[200];int vv=0;
66 for(i=0;i<n;i++)
67 {
68 if(!flag[i])
69 {
70 for(j=0;j<n;j++)
71 {
72 if(!flag1[j]&&ans1[i]==ans2[j])
73 {
74 sum+=1;
75 flag1[j]=true;
76 break;
77 }
78 }
79 }
80 }
81 printf("Case %d: %d\n",s,sum);
82 }
83 return 0;
84 }
1198 - Karate Competition的更多相关文章
- A Regularized Competition Model for Question Diffi culty Estimation in Community Question Answering Services-20160520
1.Information publication:EMNLP 2014 author:Jing Liu(在前一篇sigir基础上,拓展模型的论文) 2.What 衡量CQA中问题的困难程度,提出从两 ...
- 【CodeVS 1198】【NOIP 2012】国王游戏
http://codevs.cn/problem/1198/ 推导一翻,排好序后,直接上高精度. #include<cstdio> #include<cstring> #inc ...
- CIFAR-10 Competition Winners: Interviews with Dr. Ben Graham, Phil Culliton, & Zygmunt Zając
CIFAR-10 Competition Winners: Interviews with Dr. Ben Graham, Phil Culliton, & Zygmunt Zając Dr. ...
- Codevs 1198 国王游戏 2012年NOIP全国联赛提高组
1198 国王游戏 2012年NOIP全国联赛提高组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题目描述 Description 恰逢 H 国国庆,国王邀 ...
- Kaggle Competition Past Solutions
Kaggle Competition Past Solutions We learn more from code, and from great code. Not necessarily alwa ...
- lightoj 1198 最大权重匹配
题目链接:http://lightoj.com/volume_showproblem.php?problem=1198 #include <cstdio> #include <cst ...
- UESTC_The Most Wonderful Competition CDOJ 56
The Most Wonderful Competition Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB ...
- codeforces 883M. Quadcopter Competition 思路
M. Quadcopter Competition time limit per test 3 seconds memory limit per test 256 megabytes input st ...
- Codeforces 1082C Multi-Subject Competition(前缀+思维)
题目链接:Multi-Subject Competition 题意:给定n名选手,每名选手都有唯一选择的科目si和对应的能力水平.并且给定科目数量为m.求选定若干个科目,并且每个科目参与选手数量相同的 ...
随机推荐
- Go语言核心36讲(Go语言实战与应用二十二)--学习笔记
44 | 使用os包中的API (上) 我们今天要讲的是os代码包中的 API.这个代码包可以让我们拥有操控计算机操作系统的能力. 前导内容:os 包中的 API 这个代码包提供的都是平台不相关的 A ...
- Scala(六)【模式匹配】
目录 一.基本语法 二.匹配固定值 三.守卫 四.匹配类型 五.匹配集合 1.Array 2.List 3.元祖 4.对象和样例类 六.偏函数 七.赋值匹配 八.for循环匹配 一.基本语法 在匹配某 ...
- 二叉树——Java实现
1 package struct; 2 3 interface Tree{ 4 //插入元素 5 void insert(int value); 6 //中序遍历 7 void inOrder(); ...
- go 代理
环境变量中设置 #GO111MODULE=auto GOPROXY=https://goproxy.io 如果不第一次,则在命令行设置 go env -w GO111MODULE=on go env ...
- Maven错误收集
Eclipse 创建项目时报错 Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart:1 ...
- AOP中环绕通知的书写和配置
package com.hope.utils;import org.aspectj.lang.ProceedingJoinPoint;import org.aspectj.lang.annotatio ...
- 效验pipeline语法
目录 一.简介 二.配置 一.简介 因为jenkins pipeline不像JAVA之类的语言那样应用广泛,所以没有相关的代码检测插件. 2018年11月初,Jenkins官方博客介绍了一个VS Co ...
- 车载以太网第二弹|测试之实锤-1000BASE-T1 IOP测试实践
背景 车载以太网通信技术在汽车行业的应用速度远超预期,去年本土OEM已经上市了应用100BASE -T1的车型.今年,应用1000BASE -T1的车型预计也将会量产上市.针对测试而言,带来另外一个难 ...
- thinkPHP的多语言支持如何配置和部署
框架底层语言包位于:ThinkPHP/Lang/zh-cn.php 可以参考如何编写语言文件 第一步:项目目录下的配置文件中配置多语言支持的相关选项 以我的路径为例是Application\Commo ...
- 主流微服务一站式解决方案Spring Cloud Alibaba入门看这篇就足够了
学习路线 **本人博客网站 **IT小神 www.itxiaoshen.com 生态概述 架构演进 什么是微服务 https://martinfowler.com/microservices/ Mic ...