FZU 1350 Very Simple Problem


Very Simple Problem
Time Limit:1s
Memory limit:32M
Accepted Submit:111
Total Submit:317
During a preparation of programming contest, its jury is usually faced with many difficult tasks. One of them is to select a problem simple enough to most, if not all, contestants to solve. The difficulty here lies in diverse meanings of the term "simple"amongst the jury members. So, the jury uses the following procedure to reach a consensus: each member weights each proposed problem with a positive integer "complexity rating"(not necessarily different for different problems). The jury member calls "simplest"those problems that he gave the minimum complexity rating, and "hardest"those problems that he gave the maximum complexity rating. The ratings received from all jury members are then compared, and a problem is declared as "very simple", if it was called as "simplest"by more than a half of the jury, and was called as "hardest"by nobody. Input The first line of input file contains integers N and P, the number of jury members and the number of problems. The following N lines contain P integers in range from 0 to 1000 each - the complexity ranks. 1 <= N, P <= 100 Output Output must contain an ordered list of problems called as "very simple", separated by spaces. If there are no such problems, output must contain a single integer 0 (zero). Sample Input
4 4
1 1 1 2
5 900 21 40
10 10 9 10
3 4 3 5
Sample Output
3
Original: Northeastern Europe 2002, Far-Eastern Subregion
 
문제 풀기:
줄마다 가장 작은 문제를 찾아서 각각min수조와max수조가 존재한다.다시 min수조에서 n/2회를 초과한 수를 찾아내고 이 수는max수조에 없는 것, 즉 요구하는 수이다.출력은 순서대로 해야 합니다.
#include #include using namespace std; void sort(int a[],int n) { int i,j; int k; for(i=1;i=0 && a[j]>k) { a[j+1]=a[j]; j--; } a[j+1]=k; } } void toMinMax(int a[],int n,int b[],int c[]) { int i,j=0;int k=0; int min=1000; int max=0; int lengthA=n; for(i=0;ia[i]) min=a[i]; if(max>N>>P) { memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); memset(min,0,sizeof(min)); memset(max,0,sizeof(max)); for(i=0;i>a[j]; toMinMax(a,P,min[i],max[i]); } for(i=0;iN/2 && isValue(max,min[i][j],N,P)==false) { int flag=0; for(int m=0;m

좋은 웹페이지 즐겨찾기