<?php /* yukicoder My Practice * author: Leonardone @ NEETSDKASU */ // 解説読後 // http://yukicoder.me/problems/686/editorial $f = fgets(STDIN); $c = strlen($f); $a = [0,0,0,0,0, 0,0,0,0,0]; for ($i = 0; $i < $c; $i++) { if ($f[$i] === '.') { continue; } $a[intval($f[$i])]++; } $b = array(20105, 20063, 19892, 20011, 19874, 20199, 19898, 20163, 19956, 19841); $w = -1; $c = -1; for ($i = 0; $i < 10; $i++) { $d = $b[$i] - $a[$i]; if ($d < 0) { $w = $i; } else if ($d > 0) { $c = $i; } } echo "{$w} {$c}", PHP_EOL;