ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1491. Unreal Story

TLE #18
Posted by imeks007 15 Jan 2026 14:16
static void Main(string[] args)
{
   int n = int.Parse(Console.ReadLine());
   int[] values = new int[n];
   for (int i = 0; i < n + 1; i++)
      {
         string[] str = Console.ReadLine().Split();
         int a = int.Parse(str[0]) - 1;
         int b = int.Parse(str[1]) - 1;
         int c = int.Parse(str[2]);

         for (int j = a; j <= b; j++)
            {
               values[j] += c;
            }
      }

   Console.Write(string.Join(" ", values));
}


It's simple algorithm. How to speed it up? Which algorithm should I use?

Edited by author 21.01.2026 21:22