Submission #302716

# Submission time Handle Problem Language Result Execution time Memory
302716 2020-09-19T05:14:30 Z anishrajeev Sličice (COCI19_slicice) Java 11
Compilation error
0 ms 0 KB
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        //BufferedReader bf = new BufferedReader(new FileReader("tester.in"));
        PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
        StringTokenizer stk = new StringTokenizer(bf.readLine());
        int N = Integer.parseInt(stk.nextToken());
        int M = Integer.parseInt(stk.nextToken());
        int K = Integer.parseInt(stk.nextToken());
        int[] P = new int[N];
        stk = new StringTokenizer(bf.readLine());
        for(int i = 0; i < N; i++){
            P[i] = Integer.parseInt(stk.nextToken());
        }
        int[] B = new int[M+1];
        stk = new StringTokenizer(bf.readLine());
        for(int i = 0; i < M+1; i++){
            B[i] = Integer.parseInt(stk.nextToken());
        }
        int[][] dp = new int[N][K+1];
        for(int i = 0; i < N; i++){
            for(int c = 0; c <= K; c++){
                //d = how many u drafted before team i
                for(int d = 0; d <= c; d++){
                    if(i!=0)dp[i][c] = Math.max(dp[i][c], dp[i-1][d] + B[Math.min(P[i] + (c-d), M)]);
                    else dp[i][c] = Math.max(dp[i][c], B[Math.min(P[i] + (c-d), M)]);
                }
            }
        }
        pw.println(dp[N-1][K]);
        pw.close();
    }
}

Compilation message

slicice.java:4: error: class Main is public, should be declared in a file named Main.java
public class Main {
       ^
1 error