Блог пользователя Betlista

Автор Betlista, 15 лет назад, По-английски

Probably almost everyone here knows the contest, but I didn't find post about it here (except this one)...

Currently there is qualification round for GCJ 2012 running just now, enjoy ;-)

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
14 лет назад, скрыть # |
 
Проголосовать: нравится -9 Проголосовать: не нравится

can anybody propose a solution for qualification round's 2nd problem for small dataset.

  • »
    »
    14 лет назад, скрыть # ^ |
    ← Rev. 2  
    Проголосовать: нравится +3 Проголосовать: не нравится

    Here is what i did and passed both the tests.. initially for each test case set count=0; Scan the scores of googlers one by one in a variable say 't'

    if(t/3>=p)          //score of atleast p definitely possible 
         count++;
    else
         k=t-p;         //assuming at least one judge gave score of p
         if( k>=(2*p-2) && k>=0 && p>0)
    		count++;        //worst case score 'p' 'p-1' 'p-1' and as max diff is 1
                                    //so 's' will not be decreased
         else if(k>=(2*p-4) && s>0 && k>=0 && p>0)
         {
    		count++;        //worst case score 'p' 'p-2' 'p-2' and max diff is 2
    		s--;            //so 's' will be deceased
         }
    

    do this for all the scores and then print the final count for the test case.....

    i hope you understood the approach.

  • »
    »
    14 лет назад, скрыть # ^ |
    ← Rev. 3  
    Проголосовать: нравится +4 Проголосовать: не нравится

    Let dp[i][j] is the answer for exactly i dancers and j surprising scores. Initialization: dp[0][0] = 0. Try to add a new dancer.

    If the best result of at least p is reachable, update dp[i+1][j] = max(dp[i+1][j], dp[i][j]+1). If not, update dp[i+1][j] = max(dp[i+1][j], dp[i][j]).

    And if this result can be also surprising, update dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1). If not, update dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]).

    At the end answer will be in dp[n][s].

  • »
    »
    14 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    I don't know why people Downvoted my post even though it works....i got AC on it...if anyone has any problem then ask... I think the thought process is simple and extra space also is not required as in DP solutiom..

    Here is the Complete Code..

»
14 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Is there any way so that i can see the results filtered by Country.....