zoj-3486-Judge Internal Error
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;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.