zoj-3486-Judge Internal Error

3534 단어
Description
The online judge system developed by Zhejiang University ACM/ICPC team (that is the system used during this contest) is designed to be robust. It can execute all kinds of user-submitted programs, including unsafe or malicious ones, and remain working and stable. However, it does report mysterious “Judge Internal Error” (“JIE” in short), occasionally.
JIE happens due to various reasons, such as crashes of special judge programs, poor network conditions, incredible large test data, extremely high system load, failures of hard disks, bugs of online judge system, cosmic radiation and so on. In our experience, real world JIE often reflects one or more problematic problems. Every time JIE happens, the corresponding problem ID is written to a special system log. Given the system log, your task is to find out the ID of the most problematic problem.
Input
The first line contains an integer T (T ≈ 10), the number of test cases. The following are test cases, separated by one blank line.
For each test case, the first line contains an integer N (1 ≤ N ≤ 1000), the size of system log. Following N lines, each line contains an integer Pi (1001 ≤ Pi ≤ 9999), which is the problem ID causing JIE.
Output
For each test case, output one integer in one line, which is the ID of the most problematic problem (that is, this ID occurs the most frequently in the log). When multiple IDs occur with a same frequency, prefer the largest ID.
Sample Input
2 4 1001 1003 1003 1002
2 1001 1003
Sample Output
1003 1003
가장 많은 것을 찾았는데, 출력이 가장 큰 것은 없었다
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
    int t;
    scanf("%d",&t);
    int a[10000];
    while(t--)
    {
        memset(a,0,sizeof(a));
        int n,x;
        scanf("%d",&n);
        for(int i=0;i<n;i++)
        {
            scanf("%d",&x);
            a[x]++;
        }
        int w=0,val;
        for(int i=9999;i>=1001;i--)
        {
            if(a[i]>w)
            {
                w=a[i];
                val=i;
            }
        }
        printf("%d
"
,val); } return 0; }

좋은 웹페이지 즐겨찾기