我的问题是在SPOJ上出现了“超过时间限制”的错误。因为我认为这个错误是因为大输入,所以我需要你的帮助来找到处理大输入的最佳方法。在
让我解释一下输入和代码。在Input
The first line of the input contains test cases t(1<=t<=100). It is
followed by 2*t lines, 2 for each test case. The first line of input
for each test case contains a number n (0<=n<=10^6), followed by n
elements in the next line. Each number is from -10^3 to +10^3
下面是一个输入示例3 #number of test cases (t)
4 #number of elements that will come to next line (n) (this can be 10^6)
2 1 2 2 #this line may have 10^6 numbers
6
1 1 1 2 2 2
5
1 2 4 5 1
问题是问一个数是否出现超过n//2次。
输出示例
^{pr2}$
有关问题的详细信息Added by: Troika::Bytes Date: 2010-02-18 Time limit: 1s Source
limit: 50000B Memory limit: 256MB Cluster: Pyramid (Intel Pentium III
733 MHz) Languages: All except: PERL 6
最后是我的代码。在fro