3v4l.org

run code in 300+ PHP versions simultaneously
<?php $calc = new Calc; $calc->execute(); class Calc { private $AkaraB; private $BkaraA; private $AkaraBnoZikan; private $BkaraAnoZikan; private $Abin; private $Bbin; private $ohuku; public function __construct() { fscanf(STDIN, "%d %d", $AkaraB, $BkaraA); fscanf(STDIN, "%d %d", $AkaraBnoZikan, $BkaraAnoZikan); fscanf(STDIN, "%s", $AbinString); fscanf(STDIN, "%s", $BbinString); $this->AkaraB = $AkaraB; $this->BkaraA = $BkaraA; $this->AkaraBnoZikan = $AkaraBnoZikan; $this->BkaraAnoZikan = $BkaraAnoZikan; $this->Abin = explode(' ', $AbinString); $this->Bbin = explode(' ', $BbinString); $this->ohuku = 0; } public function execute() { $now = 0; while(true) { $end = true; foreach ($this->Abin as $key => $value) { if($now <= $value){ $now = $value; $this->Abin = array_slice($this->Abin,$key+=1); $end =false; break; } } if ($end) break; $now += $this->AkaraBnoZikan; if ($now > 24) break; $nownow = $now; $end = true; foreach ($this->Bbin as $key => $value) { if($now <= $value) { $now = $value; $this->Bbin = array_slice($this->Bbin, $key+=1); $end =false; break; } } if ($end) break; $now += $this->BkaraAnoZikan; if ($now > 24) break; $this->ohuku++; } echo $this->ohuku . "\n"; } }

preferences:
50.03 ms | 402 KiB | 5 Q