My issue
No entry for terminal type “unknown”;
using dumb terminal settings.
My code
<?php
// your code goes here
function getCharge($chargeAndParticle, $chargeAndParticleInitial, $chargeAndParticleInitialPosition){
$charge = 0;
$distancenew = 0;
$partilcesDistance = 0;
$length = count($chargeAndParticleInitial);
$length2 = count($chargeAndParticleInitialPosition);
$update = 0;
for ($z = 0; $z <= $length-1; $z++)
{
for ($x = 0; $x <= $length2-1; $x++)
{
$charge = $chargeAndParticleInitial[$z];
$partilcesDistance = (int) $chargeAndParticleInitialPosition[$x];
if($charge == 0 and $partilcesDistance >= 2)
{
$update = $update + 2;
}
else if ($charge == 1 and $partilcesDistance == 1)
{
$update = $update + 2;
}
}
}
echo $update;
}
$testcase = readline();
for ($i = 0; $i <= $testcase-1; $i++)
{
$chargeAndParticle = explode(' ', readline());
$chargeAndParticleInitial = explode(' ', readline());
$chargeAndParticleInitialPosition = explode(' ', readline());
getCharge($chargeAndParticle, $chargeAndParticleInitial, $chargeAndParticleInitialPosition);
}
Learning course: 1600 to 1800 difficulty problems
Problem Link: Charges Practice Problem in 1600 to 1800 difficulty problems - CodeChef