daily pastebin goal
17%
SHARE
TWEET

Untitled

a guest Feb 19th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.CodeDom.Compiler;
  2. using System.Collections.Generic;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Diagnostics.CodeAnalysis;
  6. using System.Globalization;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Reflection;
  10. using System.Runtime.Serialization;
  11. using System.Text.RegularExpressions;
  12. using System.Text;
  13. using System;
  14.  
  15. class Solution {
  16.  
  17.     // Complete the arrayManipulation function below.
  18.     static long arrayManipulation(int n, int[][] queries) {
  19.             long result=0;
  20.             int[] answers;
  21.             int tempCounter=0;
  22.             // get every [y,2] element
  23.             for(int y=0;y<queries.GetLength(0);y++){ // go through y rows
  24.                 for(int x=0;x<2;x++){// go through x rows skipping last element
  25.                 tempCounter=queries[y][0];
  26.                     while(tempCounter>=queries[y][0]&&tempCounter<=queries[y][1]){
  27.                         tempCounter++;
  28.                         answers[tempCounter]+=queries[y][2];
  29.                     }
  30.                    
  31.                 }
  32.             }
  33.             result=answers.Max();
  34.             return result;
  35.  
  36.     }
  37.  
  38.     static void Main(string[] args) {
  39.         TextWriter textWriter = new StreamWriter(@System.Environment.GetEnvironmentVariable("OUTPUT_PATH"), true);
  40.  
  41.         string[] nm = Console.ReadLine().Split(' ');
  42.  
  43.         int n = Convert.ToInt32(nm[0]);
  44.  
  45.         int m = Convert.ToInt32(nm[1]);
  46.  
  47.         int[][] queries = new int[m][];
  48.  
  49.         for (int i = 0; i < m; i++) {
  50.             queries[i] = Array.ConvertAll(Console.ReadLine().Split(' '), queriesTemp => Convert.ToInt32(queriesTemp));
  51.         }
  52.  
  53.         long result = arrayManipulation(n, queries);
  54.  
  55.         textWriter.WriteLine(result);
  56.  
  57.         textWriter.Flush();
  58.         textWriter.Close();
  59.     }
  60. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top