You are viewing a single comment's thread. Return to all comments →
Using Java 8 syntaxis:
public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int m = in.nextInt(); long[] output = new long[n]; IntStream.range(0,m).forEach(i -> { int a = in.nextInt()-1; int b = in.nextInt(); int k = in.nextInt(); output[a] += k; if(b < n) output[b] -= k; }); AtomicLong sum = new AtomicLong(0); System.out.print(LongStream.of(output).map(sum::addAndGet) .max().getAsLong()); in.close(); }
Seems like cookies are disabled on this browser, please enable them to open this website
Array Manipulation
You are viewing a single comment's thread. Return to all comments →
Using Java 8 syntaxis: