Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.CodeDom.Compiler;
- using System.Collections.Generic;
- using System.Collections;
- using System.ComponentModel;
- using System.Diagnostics.CodeAnalysis;
- using System.Globalization;
- using System.IO;
- using System.Linq;
- using System.Reflection;
- using System.Runtime.Serialization;
- using System.Text.RegularExpressions;
- using System.Text;
- using System;
- class Solution {
- // Complete the arrayManipulation function below.
- static long arrayManipulation(int n, int[][] queries) {
- long result=0;
- int[] answers;
- int tempCounter=0;
- // get every [y,2] element
- for(int y=0;y<queries.GetLength(0);y++){ // go through y rows
- for(int x=0;x<2;x++){// go through x rows skipping last element
- tempCounter=queries[y][0];
- while(tempCounter>=queries[y][0]&&tempCounter<=queries[y][1]){
- tempCounter++;
- answers[tempCounter]+=queries[y][2];
- }
- }
- }
- result=answers.Max();
- return result;
- }
- static void Main(string[] args) {
- TextWriter textWriter = new StreamWriter(@System.Environment.GetEnvironmentVariable("OUTPUT_PATH"), true);
- string[] nm = Console.ReadLine().Split(' ');
- int n = Convert.ToInt32(nm[0]);
- int m = Convert.ToInt32(nm[1]);
- int[][] queries = new int[m][];
- for (int i = 0; i < m; i++) {
- queries[i] = Array.ConvertAll(Console.ReadLine().Split(' '), queriesTemp => Convert.ToInt32(queriesTemp));
- }
- long result = arrayManipulation(n, queries);
- textWriter.WriteLine(result);
- textWriter.Flush();
- textWriter.Close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement