Submission details
Task:Yellow Yacht
Sender:reetta
Submission time:2018-09-13 18:15:56 +0300
Language:Java
Status:COMPILE ERROR

Compiler report

input/ohjelma.java:3: error: class Ohjelma is public, should be declared in a file named Ohjelma.java
public class Ohjelma {
       ^
1 error

Code

import java.util.Scanner;

public class Ohjelma {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int m = s.nextInt();
        int[] a = new int[m+1];
//        String[] ss = s.nextLine().split(" ");
//        
//        for (int i = 0; i < ss.length; i++) {
//            a[i] = Integer.parseInt(ss[i]);
//            
//        }
//        
        for (int i = 0; i<=m; i++) {
            a[i] = s.nextInt();
            System.out.println("i: " + i + " a[i]: " + a[i]);
        }
        
        
        
        int max = 0;
        
        for (int i = 0; i < a.length; i++) {
            for(int j = 0; j < a.length; j++){
                int sum = a[i] + a[j];
                System.out.println("i: " + i + " j: "+ j + " sum: " + sum);
                if(m-i-j < 0) continue;
                for (int l = m-(i+j); l>= 0; l--){
                    int res = sum + a[l];
                    System.out.println("res: "  + res);
                    if(res > max){
                        max = res;
                        System.out.println(max);
                    }
                }
            }
            
        }
        
        System.out.println(" HEI" + max);

    }
}