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 TEMPS = Console.ReadLine(); // the N temperatures expressed as integers ranging from -273 to 5526
- if(TEMPS == null || TEMPS.Trim().Equals("")) {
- Console.WriteLine("0");
- return;
- }
- String[] temperatures = TEMPS.Split(' ');
- if(temperatures.Count() == 0) {
- Console.WriteLine("0");
- return;
- }
- int t = Int32.Parse(temperatures[0]);
- for(int i = 1; i < temperatures.Count(); i++) {
- int nt = Int32.Parse(temperatures[i]);
- if(Math.Abs(nt) == Math.Abs(t)) {
- if(t < 0) {
- t = nt;
- }
- } else if(Math.Abs(nt) < Math.Abs(t)) {
- t = nt;
- }
- }
- Console.WriteLine(t);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement