Rezultati

Up. imeNalogaJezikRezultatČas oddaje
bitikubiti-2017 Ribiči Java 100/100OK 11. maj '17 @ 19:49

Test Točke Porabljen spomin Porabljen čas Status
#1 3/3 29,648 MiB 0,000 s OK
#2 3/3 36,914 MiB 0,000 s OK
#3 3/3 38,387 MiB 0,000 s OK
#4 3/3 89,082 MiB 0,116 s OK
#5 4/4 86,652 MiB 0,271 s OK
#6 4/4 80,621 MiB 0,282 s OK
#7 4/4 91,496 MiB 0,174 s OK
#8 4/4 88,148 MiB 0,257 s OK
#9 4/4 91,094 MiB 0,250 s OK
#10 4/4 53,152 MiB 0,000 s OK
#11 4/4 87,820 MiB 0,307 s OK
#12 4/4 50,426 MiB 0,067 s OK
#13 4/4 52,695 MiB 0,076 s OK
#14 4/4 49,844 MiB 0,089 s OK
#15 4/4 51,543 MiB 0,039 s OK
#16 4/4 86,242 MiB 0,193 s OK
#17 4/4 85,758 MiB 0,173 s OK
#18 4/4 34,359 MiB 0,000 s OK
#19 4/4 37,449 MiB 0,000 s OK
#20 4/4 30,195 MiB 0,000 s OK
#21 4/4 37,172 MiB 0,000 s OK
#22 4/4 88,496 MiB 0,201 s OK
#23 4/4 84,043 MiB 0,275 s OK
#24 4/4 41,500 MiB 0,000 s OK
#25 4/4 37,438 MiB 0,000 s OK
#26 4/4 36,094 MiB 0,000 s OK

Ocenjevani program (D.java):
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

/**
 * Created by bitikubiti-2017 on 5/11/17.
 */
public class D {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
        int N = Integer.parseInt(input[0]);
        int D = Integer.parseInt(input[1]);
        int K = Integer.parseInt(input[2]);
        int[] sums = new int[N];
        int[] all = new int[N];
        input = br.readLine().split(" ");
        for (int i = 0; i < N; i++) {
            all[i] = Integer.parseInt(input[i]);
        }
        int cur = 0;
        for (int i = 0; i < N; i++) {
            cur += all[i];
            if(i-D>=0)cur -= all[i-D];
            sums[i] = cur;
        }
        int[][] din = new int[N][K+1];
        for (int i = 0; i < N; i++) {
            for (int j = 1; j < K+1; j++) {
                int a = sums[i];
                int b = 0;
                if(i-D>=0){
                    a += din[i-D][j-1];
                }
                if(i-1 >= 0){
                    b = din[i-1][j];
                }
                din[i][j] = Math.max(a, b);
            }
        }
//        for (int i = 0; i < N; i++) {
//            System.out.println(Arrays.toString(din[i]));
//        }
//        System.out.println(Arrays.toString(sums));
        System.out.println(din[N-1][K]);
    }
}