Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- import java.math.*;
- /**
- * Auto-generated code below aims at helping you parse
- * the standard input according to the problem statement.
- **/
- class Solution {
- public static void main(String args[]) {
- Scanner in = new Scanner(System.in);
- int result=1000;
- int aux1, in2, aux2;
- int n = in.nextInt(); // the number of temperatures to analyse
- in.nextLine();
- String temps = in.nextLine(); // the n temperatures expressed as integers ranging from -273 to 5526
- String [] temp = temps.split(" ");
- if(n==0){
- result=0;
- }
- for(int i=0; i<n;i++){
- result =result;
- aux1=-result;
- in2=Integer.parseInt(temp[i]);
- aux2=-in2;
- if(in2>0){
- if(result>0){
- if(result>in2){
- result=in2;
- }
- }else{
- if(aux1>=in2){
- result=in2;
- }
- }
- }else{
- if(result>0){
- if(result>aux2){
- result=in2;
- }
- }else{
- if(aux1>aux2){
- result=in2;
- }
- }
- }
- }
- // Write an action using System.out.println()
- // To debug: System.err.println("Debug messages...");
- System.out.println(result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement