Submit | All submissions | Best solutions | Back to list |
PUCMM334 - White Hats |
There are a number of people in a room (between 2 and 100), and each of them wears a hat which is either black or white. Every person counts the number of other people wearing white hats. You are given the number counted by each person. Print the total number of people wearing white hats, or -1 if count doesn't correspond to a valid situation.
Input
The first line is N, the number of persons.
Then N space separated integers follow, each one denoting the number of white hats each person sees.
Output
Print the total number of people wearing white hats, or -1 if count doesn't correspond to a valid situation.
Example
Input: Output:
3 2
2 1 1
Input: Output:
3 3
2 2 2
Input: Output:
2 0
0 0
Input: Output:
2 -1
10 10
Added by: | Olson Ortiz |
Date: | 2013-01-01 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM32-GCC MAWK BC C-CLANG NCSHARP CPP14 CPP14-CLANG COBOL COFFEE D-CLANG D-DMD DART ELIXIR FANTOM FORTH GOSU GRV JS-MONKEY JULIA KTLN NIM OBJC OBJC-CLANG OCT PICO PROLOG PYPY PYPY3 R RACKET RUST CHICKEN SQLITE SWIFT UNLAMBDA VB.NET |
Resource: | Olimpiada de ProgramaciĆ³n PUCMM ACM-ISC 2013 |
hide comments
|
|||||
2023-01-06 17:58:28 Mitch Schwartz
Most likely the author unchecked the "Include new languages" box when setting the problem. I suppose it could make sense to include a note somewhere in the problem statement stating that newer languages are disabled, and to make sure your language is supported before writing a solution. Or instead of modifying the problem statement, to petition SPOJ devs to automate such a message for some or all language-restricted problems. (Customizing the automated message on a per-user basis is another feature that could be requested, and motivated users could also write a script (Greasemonkey/Tampermonkey/etc.) to accomplish this.) Last edit: 2023-01-06 18:54:39 |
|||||
2023-01-01 14:20:15 RR
Can't comprehend how SPOJ allow problem setters to just randomly disable languages like this. No reason to disable CPP14, PYPY, PYPY3, Rust other than to annoy people who already write code and then cannot submit. Last edit: 2023-01-01 14:21:01 |
|||||
2018-06-30 19:10:08
TLE with ios_base and cin/cout AC with scanf/printf |
|||||
2018-01-07 20:26:08
nice Q... :) dont use unsigned long long int... it may give segmentation fault... better to use long long int... |
|||||
2016-06-25 05:42:58
Weaker test cases than CRLAVEN. |
|||||
2016-06-21 22:53:12
CRNVALEN - same !! |
|||||
2016-01-29 16:23:00 cute_girl_1
forgot to delete scanf statement of crnvalen prob caused ce :( |
|||||
2016-01-03 04:37:33
lots of boundary cases make this problem not that easy. Good One!! |
|||||
2015-07-14 08:31:25
same code as The Valentine Confession only number of testcases is 1.. |
|||||
2015-06-26 11:49:45 Akshat Mathur
Take care of this- i/p -> 2 2 1 1 2 1 o/p -> -1 |