zoukankan      html  css  js  c++  java
  • Very Simple Problem

    Very Simple Problem
    Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

    Description

    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 file 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
    /*
    题意:有n位评委,给p个选手打分,让你找出very simple的选手,有这样一个标准就是给他打最低分的评委数量超过一半,并且没有评委给他打过最低分
    
    初步思路:模拟
    */
    #include <iostream>
    #include <stdio.h>
    #include <string.h>
    using namespace std;
    int n,p;
    int a[105][105];
    int cur[105];//用来标记每个选手的最低分得票 cur[i]==-1表示这个选手的过最高分,那么他的积分就不做评价
    int maxn,minn;
    void init(){
        memset(cur,0,sizeof cur);
    }
    int main(){
        // freopen("in.txt","r",stdin);
        while(scanf("%d%d",&n,&p)!=EOF){
            init();
            for(int i=0;i<n;i++){
                maxn=-1;
                minn=1001;
                for(int j=0;j<p;j++){
                    scanf("%d",&a[i][j]);
                    if(a[i][j]>maxn){
                        maxn=a[i][j];
                    }
                    if(a[i][j]<minn){
                        minn=a[i][j];
                    }
                }
                for(int j=0;j<p;j++){
                    if(a[i][j]==maxn)
                        cur[j]=-1;
                    else if(a[i][j]==minn){
                        if(cur[j]==-1)
                            continue;
                        else 
                            cur[j]++;
                    }
    
                }
            }
            // for(int i=0;i<n;i++){
            //     cout<<cur[i]<<" ";
            // }
            // cout<<endl;
            bool flag=false;
            for(int i=0;i<n;i++){
                if(cur[i]>n/2){
                    if(flag){
                        printf(" %d",i+1);
                    }else{
                        printf("%d",i+1);
                        flag=true;
                    }
                }
            }
            if(flag==false)
                printf("0");
            printf("
    ");
        }
        return 0;
    }
  • 相关阅读:
    黑客网银木马服务器曝光 14家银行网银遭监控 狼人:
    卡巴斯基实验室CE0来华启动卡巴斯基安全中国行 狼人:
    天清汉马UTM获“北京市自主创新产品”称号 狼人:
    IBM称欧亚受Conficker病毒感染最严重 狼人:
    卡巴斯基联手功夫巨星成龙 五月鸟巢开唱 狼人:
    微软4月14日起不再为所有XP用户提供安全补丁 狼人:
    卡巴斯基爱好者见面会 卡巴斯基先生与卡fans亲密互动 狼人:
    愚人节黑客以身试法 人民法院被挂马 狼人:
    微软:97%电子邮件属于垃圾邮件 狼人:
    4月3日 尤金.卡巴斯基在北大精彩演讲 狼人:
  • 原文地址:https://www.cnblogs.com/wuwangchuxin0924/p/6561696.html
Copyright © 2011-2022 走看看