CSES - Datatähti 2017 alku - Results
Submission details
Task:Kolikot
Sender:planckcons
Submission time:2016-10-04 10:31:00 +0300
Language:Java
Status:COMPILE ERROR

Compiler report

input/Kolikot.java:7: error: cannot find symbol
        Scanner input = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Kolikot
input/Kolikot.java:7: error: cannot find symbol
        Scanner input = new Scanner(System.in);
                            ^
  symbol:   class Scanner
  location: class Kolikot
2 errors

Code

import java.util.Random;

public class Kolikot {
    
    public static void main (String args[])
    {
        Scanner input = new Scanner(System.in);
        
        int[] set = new int[input.nextInt()];
        int n = set.length;
        
        for(int i = 0; i < n; i++)
        {
            set[i] = input.nextInt();
        }

        for(int i = 1; i < 1000000001; i++)
        {
            if (isSubsetSum(set, n, i) != true){
                System.out.println(i);
                break;
            }
        }
    }

    static boolean isSubsetSum(int set[], int n, int sum)
    {
        boolean subset[][] = new boolean[sum+1][n+1];

        for (int i = 0; i <= n; i++)
			subset[0][i] = true;

        for (int i = 1; i <= sum; i++)
            subset[i][0] = false;

        for (int i = 1; i <= sum; i++)
        {
			for (int j = 1; j <= n; j++)
			{
				subset[i][j] = subset[i][j-1];
				if (i >= set[j-1])
					subset[i][j] = subset[i][j] || subset[i - set[j-1]][j-1];
            }
        }
        return subset[sum][n];
    }
}