I got a "correct" with this:

use List::Util qw(sum); foreach ( 1 .. <> ) { my %votes; foreach ( 1 .. <> ) { chomp( my( $user, $vote ) = split /\s+/, <> ); $votes{$user} = $vote eq '+' ? 1 : -1; } push @scores, $_ for sum( values %votes ); } print "$_\n" for @scores;

I had to take a shower to wash off the filth after filling out their questionnaire just to submit a solution. I expect to get junk mail even though I specifically opted out of their mailing list.

It could be that I opted to produce all output after all input had been taken.

Q. Do I need to take the input for all testcases at once before processing it?

A. No, you need not take all the input at once. You can take the input for a particular test case and output the answer and then proceed to the next test case. Program should read from standard input and write into standard output. There is no need to read all data first, compute them all and then print all output. It is recommended to read and write data as simultaneously. Technically, server redirects standard stream to files. You can test you programs in the same way at home.


Dave


In reply to Re^6: Sorting challenge (Insertion sort) by davido
in thread Sorting challenge by PerlSufi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.