Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <?php
  2. /**
  3. * Auto-generated code below aims at helping you parse
  4. * the standard input according to the problem statement.
  5. **/
  6.  
  7. fscanf(STDIN, "%d",
  8. $n // the number of temperatures to analyse
  9. );
  10. $temps = stream_get_line(STDIN, 256 + 1, "\n"); // the n temperatures expressed as integers ranging from -273 to 5526
  11. $temps_arr = explode(" ", $temps);
  12. // Write an action using echo(). DON'T FORGET THE TRAILING \n
  13. // To debug (equivalent to var_dump): error_log(var_export($var, true));
  14.  
  15. //echo("result\n");
  16.  
  17. //print_r($temps_arr);
  18.  
  19. $temps_int_arr=[];
  20. foreach ($temps_arr as $key=>$value)
  21. {
  22. $temps_int_arr1[]=(int)$value;
  23. $temps_int_arr[]=abs((int)$value);
  24. }
  25.  
  26. $min=array_search(min($temps_int_arr),$temps_int_arr);
  27.  
  28. if ( array_search(-$temps_int_arr[$min], $temps_int_arr1)==false )
  29. {
  30. echo($temps_int_arr[$min]."\n");
  31. }
  32. else {
  33. echo(-$temps_int_arr[$min]."\n");
  34. }
  35.  
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement