zoj 2250 - Grandpa is Famous

题目:统计排名第二的人。

分析:计数排序+统计。

说明:大黄都说题目木有问题。他怎么会放在DP分类里啊。(2011-11-01 15:19)

#include <iostream>
#include <cstdlib>
#include <cstring>
#include <stdio.h>

usingnamespace std;

int V[ 10005 ];
int C[ 10005 ];

int cmp( constvoid* a, constvoid* b )
{
    return *(int *)b - *(int *)a;
}

int main()
{
    int N,M,I;
    while ( cin >> N >> M && (N||M) ) {
        memset( V, 0, sizeof( V ) );
        memset( C, 0, sizeof( C ) );
        for ( int i = 1 ; i <= N ; ++ i ) {
            for ( int j = 1 ; j <= M ; ++ j ) {
                scanf("%d",&I);
                ++ C[ I ];
                ++ V[ I ];
            }
        }
        qsort( C, 10001, sizeof( int ), cmp );
        int v = 0;
        for ( int i = 1 ; ; ++ i ) {
            if ( C[ i ] != C[ i-1 ] ) {
                v = C[ i ];
                break;
            }
        }
        if ( !v ) continue;
        for ( int i = 1 ; i <= 10000 ; ++ i ) {
            if ( V[ i ] == v ) {
                printf("%d ",i);
            }
        }
        printf("\n");
    }
    return 0;
}
时间: 2024-12-12 04:03:11

zoj 2250 - Grandpa is Famous的相关文章

POJ 2092 Grandpa is Famous 水

Grandpa is Famous Time Limit: 2000MS   Memory Limit: 30000K Total Submissions: 7985   Accepted: 4007 Description The whole family was excited by the news. Everyone knew grandpa had been an extremely good bridge player for decades, but when it was ann

Poj_2092 Grandpa is Famous

题目链接:http://poj.org/problem?id=2092 思路: 先统计数据,在根据Count降序排序,Count相等时按照Num升序排序:再输出Count第二大的所有Num: 代码: #include <iostream> #include <string.h> #include <algorithm> using namespace std; #define MAX_N ( 10000 + 20 ) struct Player { int Num; i

HOJ 题目分类

转自:http://blog.sina.com.cn/s/blog_65f3869301011a1o.html ******************************************************************************* 简单题(包括枚举,二分查找,(复杂)模拟,基础数据结构(栈.队列),杂题等 ****************************************************************************

2017浙江省赛 D - Let&#39;s Chat ZOJ - 3961

地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3961 题目: ACM (ACMers' Chatting Messenger) is a famous instant messaging software developed by Marjar Technology Company. To attract more users, Edward, the boss of Marjar Company, has re

zoj 3818 Pretty Poem (模拟)

ZOJ Problem Set - 3818 Pretty Poem Time Limit: 2 Seconds      Memory Limit: 65536 KB Poetry is a form of literature that uses aesthetic and rhythmic qualities of language. There are many famous poets in the contemporary era. It is said that a few ACM

ZOJ 3435 Ideal Puzzle Bobble

ZOJ Problem Set - 3435 Ideal Puzzle Bobble Time Limit: 2 Seconds      Memory Limit: 65536 KB Have you ever played Puzzle Bobble, a very famous PC game? In this game, as a very cute bobble dragon, you must keep shooting powerful bubbles to crush all t

ZOJ 3674 Search in the Wiki

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3674 Search in the Wiki Time Limit: 2 Seconds      Memory Limit: 65536 KB As we known, Searching in Wiki is an useful way for everyone who wants to get information. Wiki, a website whi

ZOJ 1654 Place the Robots (二分匹配 )

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=654 Robert is a famous engineer. One day he was given a task by his boss. The background of the task was the following: Given a map consisting of square blocks. There were three kinds of

ZOJ 3202 Second-price Auction (A)

Second-price AuctionTime Limit: 1 Second Memory Limit: 32768 KBDo you know second-price auction? It's very simple but famous. In a second-price auction, each potential buyer privately submits, perhaps in a sealed envelope or over a secure connection,