Advertisement
Guest User

Untitled

a guest
Dec 1st, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. import java.util.*;
  2. import java.io.*;
  3. import java.math.*;
  4.  
  5. /**
  6. * Auto-generated code below aims at helping you parse
  7. * the standard input according to the problem statement.
  8. **/
  9. class Solution {
  10.  
  11. public static void main(String args[]) {
  12. Scanner in = new Scanner(System.in);
  13. int result=1000;
  14. int aux1, in2, aux2;
  15. int n = in.nextInt(); // the number of temperatures to analyse
  16. in.nextLine();
  17. String temps = in.nextLine(); // the n temperatures expressed as integers ranging from -273 to 5526
  18. String [] temp = temps.split(" ");
  19. if(n==0){
  20. result=0;
  21. }
  22. for(int i=0; i<n;i++){
  23. result =result;
  24. aux1=-result;
  25. in2=Integer.parseInt(temp[i]);
  26. aux2=-in2;
  27. if(in2>0){
  28. if(result>0){
  29. if(result>in2){
  30. result=in2;
  31. }
  32. }else{
  33. if(aux1>=in2){
  34. result=in2;
  35. }
  36. }
  37. }else{
  38.  
  39. if(result>0){
  40. if(result>aux2){
  41. result=in2;
  42. }
  43. }else{
  44. if(aux1>aux2){
  45. result=in2;
  46. }
  47. }
  48. }
  49. }
  50. // Write an action using System.out.println()
  51. // To debug: System.err.println("Debug messages...");
  52.  
  53. System.out.println(result);
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement