Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.nio.charset.StandardCharsets;
- import java.util.*;
- public class Main {
- /**
- * Iterate through each line of input.
- */
- public static void main(String[] args) throws IOException {
- InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
- BufferedReader in = new BufferedReader(reader);
- String[] strNums;
- strNums = in.readLine().split(",[ ]*");
- int sequence[] = new int[strNums.length];
- int max = Integer.MIN_VALUE;
- for (int i = 0; i < strNums.length; ++i){
- sequence[i] = Integer.parseInt(strNums[i]);
- if (i - 1 > 0){
- int current = sequence[i] + sequence[i - 1];
- if (current > max){
- max = current;
- }
- }
- }
- System.out.println(max);
- // while ((line = in.readLine().split("\\s")) != null) {
- // System.out.println(line);
- // }
- // //int sequence[] =
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement