• + 3 comments

    How is your method faster than the following?

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Numerics;
    
    class Solution {
    
        static void Main(String[] args) {
            string[] tokens_n = Console.ReadLine().Split(' ');
            int n = Convert.ToInt32(tokens_n[0]);
            int m = Convert.ToInt32(tokens_n[1]);
            
            // Instantiate and populate an array of size N
            BigInteger[] arr = new BigInteger[n];
            for(int i = 0; i < n; i++)
                arr[i] = 0; 
            
            for(int a0 = 0; a0 < m; a0++){
                string[] tokens_a = Console.ReadLine().Split(' ');
                int a = Convert.ToInt32(tokens_a[0]);
                int b = Convert.ToInt32(tokens_a[1]);
                int k = Convert.ToInt32(tokens_a[2]);
                
                // Apply operation
                for(int j = a-1; j < b; j++)
                    arr[j] += k; 
            }
            
            Console.WriteLine(arr.Max(i=>i));
        }
    }