• + 0 comments

    PHP solutions

    unimportant = 0; foreach (key => $value) {

         if ($value[1] == 1) {
             `$importantContest[] = $`value[0];
         }
         else
         {
            `$unimportant+= $`value[0];
         }
    
        }
        rsort($importantContest);
    
        `$len = count($`importantContest);
        for (`$i=0; $`i < `$len; $`i++) { 
            if(`$i < $`k)
            {
                `$unimportant+=$`importantContest[$i];
            }
            else
            {
                `$unimportant-=$`importantContest[$i];
            }
    
        }
        echo $unimportant;