Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

708K 47MS.

Posted by WHQ557 at 2012-09-07 15:44:25 on Problem 2092
In Reply To:做把自以为是的好人~ ~ ~ ~ ^_^ 448K 32MS. Posted by:WHQ557 at 2012-09-07 15:43:36
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<fstream>
#include<cmath>
#include<vector>
#include<set>
#include<cstring>
#include<math.h>

using namespace std;

short a[10001];

void scan(short &n){
    n=0;
    char c;
    while(c=getchar(),'0'<=c&&c<='9') n=n*10+c-'0';
    if(!n) scan(n);
}

int main(){
    //freopen("in.txt","r",stdin);
    short n,m;
    while(scanf("%hd%hd\n",&n,&m),n&&m){
        memset(a,0,20002);
        short i,j,x,max=-1,second_max=-1;
        for(i=0;i<n;++i){
            for(j=0;j<m;++j){
                scan(x);
                ++a[x];
                if(a[x]>=max) max=a[x];
                else if(a[x]>second_max) second_max=a[x];
            }
        }
        for(i=0;i<10001;++i)if(a[i]&&a[i]!=max&&a[i]>second_max){
            second_max=a[i];
        }
        for(i=0;i<10001;++i)if(a[i]==second_max){
            printf("%hd",i); putchar(' ');
        }
        putchar('\n');
    }
    return 0;
}


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator