TOJ 2877.Paradox With Averages

题目链接:http://acm.tju.edu.cn/toj/showp2877.html


2877.    Paradox With Averages
Time Limit: 3.0 Seconds    Memory Limit: 65536K
Total Runs: 2713    Accepted Runs: 769     Multiple test files



One well-known joke goes as follows: If a bad Computer Science student drops out of college and goes to a different college to study Economics instead, he will increase the average intelligence on both colleges.

In this problem we will investigate the maths behind this joke.

Problem specification

Given the list of student IQs for each of the two colleges, find the number of students of Computer Science that can make the joke true - that is, compute the size of the set { S | S is a student of Computer Science, and if he went to study Economics, both average IQs would increase }.

Input

The first line of the input file contains an integer  T specifying the number of test cases. Each test case is preceded by a blank line.

Each test case looks as follows: The first line two positive integers NCS and NE - the number of students of Computer Science and Economics, respectively. The number of Computer Science students will be at least 2.

The following lines contain a total of NCS + NE whitespace-separated positive integers giving the IQs of all the students. The first NCS students mentioned in the input are Computer Science students, the remaining ones study Economics.

You can assume that both NCS and NE are not more than 200,000, and the IQ of each student is not more than 100,000

Output

For each test case output a single line with a single integer - the number of Computer Science students that would cause the funny event to happen.

Sample Input

1

5 5
100 101 102 103 104
98 100 102 99 101

Sample Output

1

Hint: The average Computer Science IQ increases only if the leaving student is #1 or #2. Student #1 is too dumb to raise the average IQ for Economics, thus only student #2 remains and the answer is 1.



Source: TJU Team Selection Contest 2007 (4)
Submit   List    Runs   Forum   Statistics


水题:

#include <stdio.h>
int main(){
	int cs[200001],e,cast,ncs,ne,num;
	double acs,ae;
	scanf("%d",&cast);
	while(cast--){
		acs=ae=0;
		num=0;
		scanf("%d%d",&ncs,&ne);
		for(int i=0;i<ncs;i++){
			scanf("%d",&cs[i]);
			acs+=cs[i];
		}
		for(int j=0;j<ne;j++){
			scanf("%d",&e);
			ae+=e; 
		}
		acs/=ncs;ae/=ne;
		for(int i=0;i<ncs;i++)
			if(cs[i]<acs&&cs[i]>ae)
				num++;
		printf("%d\n",num);
	}
} 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值