Advertisement
Guest User

Untitled

a guest
Feb 12th, 2017
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. <?php
  2.  
  3. class Person{
  4. public $name;
  5. public $age;
  6.  
  7. function __construct(string $name, int $age)
  8. {
  9. $this->name=$name;
  10. $this->age = $age;
  11. }
  12. }
  13.  
  14. $inp = trim(intval(fgets(STDIN)));
  15. $allp = [];
  16. $maxage = 0;
  17.  
  18. for ($i=0;$i<$inp;$i++) {
  19. $info = explode(" ", trim(fgets(STDIN)));
  20. $person = new Person($info[0], intval($info[1]));
  21. $allp[$person->age] = $person->name;
  22. if($person->age > $maxage) {
  23. $maxage = $person->age;
  24. }
  25. }
  26.  
  27. echo $allp[$maxage] . " " . $maxage;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement