1851 - Bridge Coverage Systems
Forum rules
Remember that posting AC code is not allowed here. If you are going to ask a question or to post a solution, describe your algorithm instead. Posting AC code will be penalized.
Remember that posting AC code is not allowed here. If you are going to ask a question or to post a solution, describe your algorithm instead. Posting AC code will be penalized.
- ymondelo20
- Posts: 1968
- Joined: 8 years ago
- Location: Universidad de las Ciencias Informáticas
- Gender:
- Contact:
Re: 1851 - Bridge Coverage Systems
whye i received time limited exeded if mi code is simple like this:
Code: Select all
using System;
namespace _1851_Bridge_Coverage_Systems
{
class Program
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int[] towers = new int[n];
int may = int.MinValue;
for (int i = 0; i < n; i++)
{
int h = int.Parse(Console.ReadLine());
towers[i] = h;
if (h > may)
{
may = h;
}
}
foreach (int x in towers)
{
Console.WriteLine(may - x);
}
}
}
}
Re: 1851 - Bridge Coverage Systems
Your algorithm is very fine and very fast, I can't understand why you received an TLE. Try it in Ruby with the same algorithm. I did the same like you in Ruby, and I received an Accepted. 

Re: 1851 - Bridge Coverage Systems
Maybe if you do "may = towers.Max()" when you read it all, you can eliminate the "if(h > may){ }" sentence. I do that and I received an Accepted