Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Auto-generated code below aims at helping you parse
- * the standard input according to the problem statement.
- **/
- fscanf(STDIN, "%d",
- $n // the number of temperatures to analyse
- );
- $temps = stream_get_line(STDIN, 256 + 1, "\n"); // the n temperatures expressed as integers ranging from -273 to 5526
- $temps_arr = explode(" ", $temps);
- // Write an action using echo(). DON'T FORGET THE TRAILING \n
- // To debug (equivalent to var_dump): error_log(var_export($var, true));
- //echo("result\n");
- //print_r($temps_arr);
- $temps_int_arr=[];
- foreach ($temps_arr as $key=>$value)
- {
- $temps_int_arr1[]=(int)$value;
- $temps_int_arr[]=abs((int)$value);
- }
- $min=array_search(min($temps_int_arr),$temps_int_arr);
- if ( array_search(-$temps_int_arr[$min], $temps_int_arr1)==false )
- {
- echo($temps_int_arr[$min]."\n");
- }
- else {
- echo(-$temps_int_arr[$min]."\n");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement