CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • All Contests
    • June Long 2012
    • May Cook-Off
    • May Long 2012
  • DISCUSS
    • Forums
    • Blog
    • Wiki
    • Facebook
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
    • Event Calendar
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » February 2012 Challenge » Count of Maximum

Count of Maximum

Problem code: MAXCOUNT

  • All Submissions

All submissions for this problem are available.

Given an array A of length N, your task is to find the element which repeats in A maximum number of times as well as the corresponding count. In case of ties, choose the smaller element first.

Input

First line of input contains an integer T, denoting the number of test cases. Then follows description of T cases. Each case begins with a single integer N, the length of A. Then follow N space separated integers in next line. Assume that 1 <= T <= 100, 1 <= N <= 100 and for all i in [1..N] : 1 <= A[i] <= 10000

Output

For each test case, output two space separated integers V & C. V is the value which occurs maximum number of times and C is its count.

Example

Input:
2
5
1 2 3 2 5
6
1 2 2 1 1 2

Output:
2 2
1 3

Description:
In first case 2 occurs twice whereas all other elements occur only once. 
In second case, both 1 and 2 occur 3 times but 1 is smaller than 2.


Author: yellow_agony
Date Added: 18-01-2012
Time Limit: 1 sec
Source Limit: 50000 Bytes
Languages: ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC


  • Submit

Comments

  • Login or Register to post a comment.

sir as i have run the code in

saurabhzx @ 1 Feb 2012 05:28 PM
sir as i have run the code in my compiler n it is giving all answer correctly bt here the compiler is showing that it is wrong answer...

Getting runtime errror while

kirti_1 @ 1 Feb 2012 05:44 PM
Getting runtime errror while submitting solution. I used erlang language and my solution memory is 7.9M. My Solution ID for this solution is 814771. please look into this problem and reply back.

hi there...can we import java

multimandy @ 1 Feb 2012 06:15 PM
hi there...can we import java library directly like.. import java.util.*;

yes... only java libraries..

calc_saransh @ 1 Feb 2012 06:52 PM
yes... only java libraries.. no external ones...

can u please say what is

deba_22 @ 1 Feb 2012 08:42 PM
can u please say what is wrong in my answer ??

can u tell me for which case

bnslanuj @ 1 Feb 2012 09:02 PM
can u tell me for which case i m getting WA....plzzz

Please read

nikhil_adm @ 1 Feb 2012 09:07 PM
Please read http://www.codechef.com/wiki/faq#Why_do_I_get_Wrong_Answer and http://www.codechef.com/wiki/faq#Why_do_I_get_a_Runtime_exception

my code is running fine in my

deba_22 @ 1 Feb 2012 09:12 PM
my code is running fine in my pc, i have tried with various random test cases.. if u can pls tell me the mistake..

it will also be helpful if u

deba_22 @ 1 Feb 2012 09:13 PM
it will also be helpful if u provide a sample test case where my code fails..

@deba_22 : Sorry, but we

nikhil_adm @ 1 Feb 2012 09:18 PM
@deba_22 : Sorry, but we can't provide any additional help. You're expected to find your bug yourself. If however there is a lack of clarity with problem statement, please point out.

iam gettin an run time error

dakeee @ 1 Feb 2012 10:06 PM
iam gettin an run time error please look into my sol my sol id is 816713

Sir, iam getting Runtime

manishpatel @ 1 Feb 2012 11:01 PM
Sir, iam getting Runtime error . while mycode is correct ID-817089.plz check it

sir as i have run the code in

qqqqqq @ 1 Feb 2012 11:36 PM
sir as i have run the code in my compiler n it is giving all answer correctly bt here the compiler is showing that it is wrong answer... cheak it

am getting the ans corect bt

nyfer @ 1 Feb 2012 11:54 PM
am getting the ans corect bt here it shows its wrong

hey admin plz clarify whether

arpitjindal @ 1 Feb 2012 11:59 PM
hey admin plz clarify whether in between V &C there are 2 space or one, in output ???

I h`ve tried many times by

shankar_seek @ 2 Feb 2012 12:25 AM
I h`ve tried many times by running my code in the way u mentioned in the FAQ,but still i am getting wrong answer on submitting while i am getting correct answer here.could u plz say y so?

admin, i am not getting run

kafee786 @ 2 Feb 2012 12:41 AM
admin, i am not getting run time error type,while i hover my mouse over the icon. my submission id 817809 .Please help me to resolve my problem.

why its showing wrong answer

prashant171992 @ 2 Feb 2012 01:13 AM
why its showing wrong answer despite displaying the correct answers of all the possible test cases ????

why can't we submit solution

rohit_p @ 2 Feb 2012 02:15 AM
why can't we submit solution in c or c99 ....... a msg is displayed that you cant submit in this language

Hi my code is working

chakri1vr1 @ 2 Feb 2012 03:50 AM
Hi my code is working correctly in my compiler but it is showing run time error here--can anyone plz help???

@arpitjindal - Check the

nikhil_adm @ 2 Feb 2012 09:57 AM
@arpitjindal - Check the output specification. There is 1 space between V & C.

@rohit_p : As you can see

nikhil_adm @ 2 Feb 2012 10:06 AM
@rohit_p : As you can see there are several accepted solutions in C. So you must be doing something wrong. Please try again and report back if the problem persists.

when I submitted solution of

ajayk @ 2 Feb 2012 10:45 AM
when I submitted solution of this program I have got time limit exceed.can you help how to reduce execution time of program.thanx

I have a question.Do I have

deepai_dutta @ 2 Feb 2012 11:44 AM
I have a question.Do I have to enforce the checking of the number of integers??..i.e suppose for a test case N=5.Can its corresponding line be [1 2 3 4 5 6}(in the question)or it will be only 5 numbers?

shit man..wht the f##k... hey

aradhya1992 @ 2 Feb 2012 12:49 PM
shit man..wht the f##k... hey admin..ths q spoiled my whole night... codechef dosn't support string lib functions!!! as soon I remvd it I got "correct answer",... but at last q was very easy..logic struck in my mind in 2 sec.. :)

string functions are not

abhinandanr @ 2 Feb 2012 01:18 PM
string functions are not supported...if u get "wrong answer" then remove string functions and post it again

@deepai_dutta : You can

nikhil_adm @ 2 Feb 2012 04:09 PM
@deepai_dutta : You can assume that the test data is sound and correct.

hello, i want to ask? why i

sangmaestro @ 2 Feb 2012 04:47 PM
hello, i want to ask? why i always get "Runtime Error", I used pascal. If I compile at ideone.com its work well...

Hello, I want to ask why I

tabrizian @ 2 Feb 2012 05:00 PM
Hello, I want to ask why I always get "Runtime Error" while it's working in visual studio. I used C++.

Runtime error plz

tj91 @ 2 Feb 2012 05:40 PM
Runtime error plz help..............

its working fine on my

tj91 @ 2 Feb 2012 05:56 PM
its working fine on my machine here "runtime error"

my mistake :P

tj91 @ 2 Feb 2012 06:08 PM
my mistake :P

my runtime comes out to be

vermaankush91 @ 2 Feb 2012 07:54 PM
my runtime comes out to be 3.63 but my code is sucessful is my code accepted????

Thank you CodeChef....

tru3liar @ 2 Feb 2012 08:11 PM
Thank you CodeChef....

@admin hello sir just wanted

innocent_chef @ 2 Feb 2012 08:13 PM
@admin hello sir just wanted to ask my code is giving a runtime error despite everything sounds fine, may be I am getting wrong but it really worths. Please help me out.

I found out my error where

innocent_chef @ 2 Feb 2012 08:27 PM
I found out my error where I'm getting wrong(as earlier it was Runtime Error) but now it is giving a WA. Do I need to print output in this format cout << ANS << endl; or cout << ANS; will work Please clarify, an humble request.

@admin: can u tell me why i

saurabhskj @ 2 Feb 2012 08:36 PM
@admin: can u tell me why i am getting the wrong answer ?? Also can we use the string func. to take the input separated by integers?

Getting runtime errror while

w3school @ 2 Feb 2012 09:40 PM
Getting runtime errror while submitting solution. I used c language and my solution memory is 1.7M. My Solution ID for this solution is 822081. please look into this problem and reply back.

Can i get to know the

vickysirwani @ 3 Feb 2012 01:19 AM
Can i get to know the required run time complexity???

wrong ans.. it works fine on

pyaaripari @ 3 Feb 2012 01:32 AM
wrong ans.. it works fine on ideone.com for all cases.. but here it shows wrong ans.. :(

@admin: as i have run the

brinpage1998 @ 3 Feb 2012 12:18 PM
@admin: as i have run the code in my compiler ,its working properly. but here its showing 'wrong answer'..

*Solution ID:824262

brinpage1998 @ 3 Feb 2012 12:20 PM
*Solution ID:824262

sir the code generates no

shailu95 @ 3 Feb 2012 06:03 PM
sir the code generates no error in my cpp compiler but here it shows a compilation error! please ckeck the code.

@shailu95:: Click on my

ritesh_gupta @ 3 Feb 2012 06:38 PM
@shailu95:: Click on my submissions on top right of this page ,then click on the compilation error(inverted yellow triangle) symbol ,it will say why are you getting compilation error along with the line number??

admin i have run the code in

sagar55 @ 3 Feb 2012 07:13 PM
admin i have run the code in my compiler n it is giving all answer correctly bt here the compiler is showing that it is wrong answer.why??

which compiler is used for c

footcric @ 3 Feb 2012 09:16 PM
which compiler is used for c program ??

i think here gcc is used...

footcric @ 3 Feb 2012 09:17 PM
i think here gcc is used...

@admin codechef dosn't

phaniram @ 3 Feb 2012 11:37 PM
@admin codechef dosn't support string lib functions!!! wht's this about?

-----------------------------

srb45 @ 4 Feb 2012 04:51 AM
--------------------------------------------- Language Field is required. You cant submit in this language --------------------------------------------- I am getting this, when submitting code. Im submitting it in C++(gcc 4.3) My code is in C++. Whats the problem?

Hi my code is working fine in

show_kat @ 4 Feb 2012 05:40 PM
Hi my code is working fine in my computer but on your site it is showing wrong answer can you please explain the reason Thanks.

My code works fine in eclipse

nikhilsv92 @ 5 Feb 2012 12:53 AM
My code works fine in eclipse but here it shows wrong answer... can we use all java libraries like sorting,threads etc...

my program working correct on

crazycoder_sns @ 5 Feb 2012 03:49 AM
my program working correct on ideone site which uses the same engine you are using .....but on ur site its shows wrong answer what is that.....what do you think we have an extra time for wasting ......why are u admin ...you dont help anything .....just say read the problem again ....output specification etc.......................please stop this site ...dont waste students time that is very costly for them....

i am getttin correct answer

nirwan @ 5 Feb 2012 05:53 AM
i am getttin correct answer on my compiler bloodshed devc++ but wrong answer here ...................plzzzzz give a test case for which i should try .................................

what is runtime error SIGABRT

deba_22 @ 5 Feb 2012 10:59 AM
what is runtime error SIGABRT ???

Admin Some one by name

manish_ranjan @ 5 Feb 2012 05:10 PM
Admin Some one by name aradhya1992 has pointed out that String functions are not supported and they end up giving wrong answer is that correct

any one plz give me....some

chaubey12 @ 5 Feb 2012 09:43 PM
any one plz give me....some more example

wat is wrong in my code....is

chaubey12 @ 5 Feb 2012 09:45 PM
wat is wrong in my code....is any body help me...

well can any one tell me that

crazycoder_sns @ 6 Feb 2012 12:59 AM
well can any one tell me that can we use hash method or any other method which is suitable for this problem...:-)

what is source limit? Is it

lohithvgsn @ 6 Feb 2012 05:00 PM
what is source limit? Is it something related to the total amount of memory a prog can take?

hi there...does wrong answer

multimandy @ 6 Feb 2012 05:54 PM
hi there...does wrong answer means output is incorrect or the format in which output is expected is incorrect...bcz i have tried my solution on mine compiler and it gives me correct answer,but here i am getting error....

i want some more examples...

chaubey12 @ 6 Feb 2012 07:04 PM
i want some more examples...

When you are getting correct

sampath101 @ 6 Feb 2012 10:55 PM
When you are getting correct result in local machine, but wrong answer in this site. One problem might be (one I have faced) - You have to display each test case result in a new line. If you do not display each result in a new line, even though your answer is correct, it will show wrong answer.

What is Runtime Error: NZEC?

sjanaki @ 7 Feb 2012 01:03 PM
What is Runtime Error: NZEC?

I am getting a run time error

redstar @ 8 Feb 2012 08:31 AM
I am getting a run time error I am getting correct in my local machine

@admin: What should be the

dhin730 @ 8 Feb 2012 05:22 PM
@admin: What should be the output when all of the elements in the array are unique?

@dhin730 ... then print the

devilsliveon @ 8 Feb 2012 08:45 PM
@dhin730 ... then print the output as: smallest element {space} 1

what is worng in my code , it

daggoluanil @ 9 Feb 2012 11:14 AM
what is worng in my code , it is fine in m local machine

I repeat with emphasis that

nikhil_adm @ 9 Feb 2012 11:19 AM
I repeat with emphasis that discussing solutions, algorithms or test cases here would invite a direct disqualification. DO NOT share your program / solution here.

hey my java program is

giri7io @ 9 Feb 2012 08:22 PM
hey my java program is working perfect ...may i know what's wrong in my program? i hav imported java libraries..and i tested my program in the way u hav said in FAQ can u please consider my program.... IT'S WORKING PERFECT in my system atleast tell us how it gonna take input file and test it :P i hav read FAQ :P but need explanation for rejecting my submission

hav u observed?? not even

giri7io @ 9 Feb 2012 08:33 PM
hav u observed?? not even single JAVA language submission for this problem... check ur system yarr... my java program is working perfect...i guess there is problem in ur compiling system every one can't code in just C or C++ ... allow JAVA too :P ... if u do so then y not even single JAVA successfull submission?

I agree with you, I have

crooked_coder @ 10 Feb 2012 08:39 AM
I agree with you, I have tested every possible borderline case. The code is running fine on my system. There were days on Codechef when admins were quite active.....

Hey admin, Iam confused. You

angelin_nadar @ 10 Feb 2012 11:37 AM
Hey admin, Iam confused. You have said "nikhil_adm @ 2 Feb 2012 09:57 AM @arpitjindal - Check the output specification. There is 1 space between V & C." whereas problem statement states" Output For each test case, output two space separated integers V & C. V is the value which occurs maximum number of times and C is its count. Which should i follow?"

@admin.... My code is running

king_3105 @ 10 Feb 2012 01:58 PM
@admin.... My code is running fine on my system on gcc 4.3.2 compiler but I am getting a SGISGEV error on the platform!

whats wrong with my programme

aabhi @ 11 Feb 2012 04:20 AM
whats wrong with my programme ??,i am getting the desired output on my system..

can we still submit

bigaditya @ 11 Feb 2012 03:14 PM
can we still submit code???even though the competition is over?

did anyone notice there are

shishirgarg @ 11 Feb 2012 03:21 PM
did anyone notice there are absolutely no correct java submissions? I thought mine worked fine, but it said wrong answer.

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold
CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of algorithms, computer programming and programming contests. At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and another smaller programming challenge in the middle of the month. We also aim to have training sessions and discussions related to algorithms, binary search, technicalities like array size and the likes. Apart from providing a platform for programming competitions, CodeChef also has various algorithm tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our programming contest judge accepts solutions in over 35+ programming languages. Preparing for coding contests were never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming challenges that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly coding contest and the shorter format Cook-off coding contest. Put yourself up for recognition and win great prizes. Our programming contests have prizes worth up to Rs.20,000 and $700lots more CodeChef goodies up for grabs.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be a part of CodeChef's Forums and interact with all our programmers - they love helping out other programmers and sharing their ideas. Have discussions around binary search, array size, branch-and-bound, Dijkstra's algorithm, Encryption algorithm and more by visiting the CodeChef Forums and Wiki section.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. You can also host a coding contest for your institute on CodeChef, organize an algorithm event and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com