Submission #302717

# Submission time Handle Problem Language Result Execution time Memory
302717 2020-09-19T05:15:54 Z anishrajeev Sličice (COCI19_slicice) Java 11
90 / 90
455 ms 12408 KB
import java.io.*;
import java.util.*;

public class slicice {
    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();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 90 ms 10812 KB Output is correct
2 Correct 87 ms 10616 KB Output is correct
3 Correct 455 ms 12184 KB Output is correct
4 Correct 448 ms 12192 KB Output is correct
5 Correct 454 ms 12408 KB Output is correct
6 Correct 449 ms 12308 KB Output is correct
7 Correct 446 ms 12156 KB Output is correct
8 Correct 444 ms 12280 KB Output is correct
9 Correct 445 ms 12172 KB Output is correct
10 Correct 453 ms 12280 KB Output is correct