Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.IO;
- using System.Text;
- using System.Collections;
- using System.Collections.Generic;
- /**
- * Auto-generated code below aims at helping you parse
- * the standard input according to the problem statement.
- **/
- class Solution
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine()); // the number of temperatures to analyse
- string[] inputs = Console.ReadLine().Split(' ');
- if (n == 0) {
- Console.WriteLine(0);
- return;
- }
- int positive = 5527;
- int negative = -274;
- for (int i = 0; i < n; i++)
- {
- int t = int.Parse(inputs[i]); // a temperature expressed as an integer ranging from -273 to 5526
- if (t == 0) {
- Console.WriteLine(0);
- return;
- }
- if (t > 0 && t < positive)
- positive = t;
- else if (t < 0 && t > negative)
- negative = t;
- }
- Console.WriteLine ((positive.CompareTo (Math.Abs (negative))) < 1 ? positive : negative);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement