poj 2535 Very Simple Problem

开始题意搞错了,一直以为是最简单的问题才行。。。

后来看discuss才发现只要简单就可以了,里面看到一个很不错的题意解释。。。

问题: n个人给p道题打分,一道题是最容易题的条件:
       该题被评为最简单的次数要过半,而且该题没有被任何评委评为最难。

方法: 可设置3个数组,数组A用来读入数据,数组B纪录对应的题目是否被
打成“最难”的了, 数组C纪录该道题被评委打成“最简单”的次数.当然
这个“最难”和“最简单”只是针对这个评委给这P道题目的打分了。

所以,每次读入一行时,判断最难的题和最简的题(即该评委给分给的最高和最低的),
然后将对应的B置为1,对应的C增加1。

最后: 再遍历所有题目,“没有被标记为最难的以及被标记为最简单的数目过半的题”就是简单题。

思路也很清晰。

#include <stdio.h>
#include <string.h>

int problemRank[102];
int isHardest[102];

int main()
{
	int N,P;
	int minNum,maxNum;
	scanf("%d%d",&N,&P);

	int i,j;
	int nowProblemScore[102];

	memset(problemRank,0,sizeof(problemRank));
	memset(isHardest,0,sizeof(isHardest));
	for(i=0;i<N;i++)
	{
		minNum=0x7fffffff;
		maxNum=-1;
		for(j=0;j<P;j++)
		{
			scanf("%d",&nowProblemScore[j]);

			if(nowProblemScore[j]<minNum)
				minNum=nowProblemScore[j];

			if(nowProblemScore[j]>maxNum)
				maxNum=nowProblemScore[j];
		}

		//printf("minNum == %d\n",minNum);  //ok

		for(j=0;j<P;j++)
		{
			if(minNum == nowProblemScore[j])
				problemRank[j]++;

			if(maxNum == nowProblemScore[j])
				isHardest[j]=1;
		}
	}

	/*for(j=0;j<P;j++)
		printf("%d ",problemRank[j]);
	printf("end\n");*/

	for(i=0;i<P;i++)
		if(isHardest[i]==0 && problemRank[i]>N/2)
		{
			printf("%d",i+1);
			break;
		}

		if (i == P)
		{
			printf("0\n");
			return 0;
		}

	//最后的输出
	for(j=i+1;j<P;j++)
		if(isHardest[j]==0 && problemRank[j]>N/2)
			printf(" %d",j+1);

	printf("\n");

	return 0;
}
时间: 2024-08-22 14:51:09

poj 2535 Very Simple Problem的相关文章

poj 3468 A Simple Problem with Integers

点击打开链接poj 3468 思路:线段树成段更新 分析: 1 最基础的线段树的成段更新的题目,我们只要建好线段树然后进行更新即可 2 注意由于输入的数最大为10^9,因此我们应该使用long long,区间的和已经区间的延时标记都要为long long 代码: #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; type

poj 3486 A Simple Problem with Integers(树状数组第三种模板改段求段)

/* 树状数组第三种模板(改段求段)不解释! 不明白的点这里:here! */ #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #define N 100005 using namespace std; typedef long long LL; LL ss[N], B[N], C[N]; int n, m; void addB(int x, int k){/

【北大夏令营笔记-线段树】POJ3468-A Simple Problem with Integers

A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 57993 Accepted: 17658 Case Time Limit: 2000MS Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of ope

hdu 5349 MZL&amp;#39;s simple problem

hdu 5349 的传送门 Problem Description A simple problem Problem Description You have a multiple set,and now there are three kinds of operations: 1 x : add number x to set 2 : delete the minimum number (if the set is empty now,then ignore it) 3 : query the

hd2522A simple problem

A simple problem Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3118    Accepted Submission(s): 1135 Problem Description Zty很痴迷数学问题..一天,yifenfei出了个数学题想难倒他,让他回答1 / n.但Zty却回答不了^_^. 请大家编程帮助他.   I

poj 1350 Cabric Number Problem

这道题目肯定是不难的,但是的的确确有很多小问题很懊恼,其实在比赛中就最怕这种题,因为那个时候大家的心情都是非常紧张的,这种题就是总是WA,就是不知道为什么...... 题意比较简单:就是输入一个数(各个数位不全相同,且数字的长度为4),将它的各位从大到小排得的数maxnum和各位从小到大排的数minnum相减,反复循环直至值为0或者6147.且如果开头有0那么0不参与排序. 陷阱有2个:1.如果输入的数小于4位或者大于4位都输出No!!如果忽略了这一点就会OLE. 2.最恶心的,就是题目里面没说

poj 1298 The Hardest Problem Ever

题目是很水的,要注意两点,一个就是字符串必须比放入的数组多一个,如这道题strlen(a)=26,sizeof(a)=27... 还有一点就是gets()函数可以输入空格,不能输入回车,但是s%不能输入空格,也不能输入回车 AC的代码: #include <stdio.h> #include <string.h> char a[27] = {'V','W','X','Y','Z', 'A','B','C','D','E','F','G', 'H','I','J','K','L','

【JAVA大数训练】A + B Problem II

A + B Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 196702    Accepted Submission(s): 37626 Problem Description I have a very simple problem for you. Given two integers A and B, yo

[ACMcoder] A + B Problem II

Problem Description I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B. Input The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines fol