Language: Java

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public int c = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int a[] = new int[m + 1];
            int f[][] = new int[n + 10][10];
            for (int i = 1; i <= m; i++) {
                a[i] = in.nextInt();
                f[c[a[i]]][a[i]] = 1;
            }
            Arrays.sort(a);
            for (int i = 2; i < n; i++) {
                for (int j = 1; j <= m; j++) {
                    if (f[i][a[j]] > 0) {
                        for (int k = 1; k <= m; k++) {
                            f[i + c[a[k]]][a[k]] = Math.max(f[i + c[a[k]]][a[k]], f[i][a[j]] + 1);
                        }
                    }
                }
            }

            int k = 0;
            for (int i = n; i > 0; i -= c[a[k]]) {
                k = 0;
                for (int j = 1; j <= m; j++) {
                    if (f[i][a[j]] > 0 && f[i][a[k]] <= f[i][a[j]]) k = j;
                }
                out.print((char) ('0' + a[k]));
            }
            out.println();

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Compiler output:
Main.java:30: error: illegal initializer for int
        public int c = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
                       ^
Main.java:39: error: array required, but int found
                f[c[a[i]]][a[i]] = 1;
                   ^
Main.java:46: error: array required, but int found
                            f[i + c[a[k]]][a[k]] = Math.max(f[i + c[a[k]]][a[k]], f[i][a[j]] + 1);
                                   ^
Main.java:46: error: array required, but int found
                            f[i + c[a[k]]][a[k]] = Math.max(f[i + c[a[k]]][a[k]], f[i][a[j]] + 1);
                                                                   ^
Main.java:53: error: array required, but int found
            for (int i = n; i > 0; i -= c[a[k]]) {
                                         ^
5 errors