Rezultati

Up. imeNalogaJezikRezultatČas oddaje
JayZCrew Ribiči C++ 100/100OK 11. maj '17 @ 20:09

Test Točke Porabljen spomin Porabljen čas Status
#1 3/3 3,086 MiB 0,004 s OK
#2 3/3 3,387 MiB 0,016 s OK
#3 3/3 3,348 MiB 0,010 s OK
#4 3/3 6,133 MiB 0,110 s OK
#5 4/4 6,098 MiB 0,141 s OK
#6 4/4 6,094 MiB 0,129 s OK
#7 4/4 6,094 MiB 0,129 s OK
#8 4/4 6,137 MiB 0,129 s OK
#9 4/4 6,133 MiB 0,135 s OK
#10 4/4 4,566 MiB 0,057 s OK
#11 4/4 6,098 MiB 0,135 s OK
#12 4/4 5,328 MiB 0,086 s OK
#13 4/4 5,379 MiB 0,086 s OK
#14 4/4 5,375 MiB 0,086 s OK
#15 4/4 6,137 MiB 0,086 s OK
#16 4/4 6,137 MiB 0,118 s OK
#17 4/4 6,098 MiB 0,118 s OK
#18 4/4 3,066 MiB 0,004 s OK
#19 4/4 3,070 MiB 0,004 s OK
#20 4/4 3,074 MiB 0,004 s OK
#21 4/4 3,105 MiB 0,004 s OK
#22 4/4 6,137 MiB 0,106 s OK
#23 4/4 6,094 MiB 0,146 s OK
#24 4/4 3,391 MiB 0,010 s OK
#25 4/4 3,391 MiB 0,010 s OK
#26 4/4 3,383 MiB 0,016 s OK

Ocenjevani program (neki.cpp):
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int main(){
    int n,d,k;
    cin >> n >> d >> k;
    //cout << "n:" << n << " " << d  << " " << k << std::endl;
    long int A[n];
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    //for(int i = 0; i < n; i++){
    //    cout << A[i] << " ";
    //}
    long int Repi[n];
    long int vsota = 0;
    for(int i = n-1;i >= n-d; i--){
        //cout << "Burek" << std::endl;
        vsota = vsota + A[i];
        Repi[i] = vsota;
        //cout << i << " " << Repi[i] << std::endl;
    }
    for(int i = n-d-1; i >= 0; i--){
        vsota = vsota + A[i];
        vsota = vsota - A[i+d];
        Repi[i] = vsota;
    }

    //for(int i = 0; i < n; i++){
    //    cout << Repi[i] << " ";
    //}
    //cout << std::endl;

    long int zadni_dan[n];
    for(int i = n-d; i < n; i++){
        zadni_dan[i] = Repi[i];
    }
    for(int i = n-d-1; i >= 0;i--){
        zadni_dan[i] = max(zadni_dan[i+1],Repi[i]);
    }

    //for(int i = 0; i < n; i++){
    //    cout << zadni_dan[i] << " ";
    //}
    //cout << std::endl;

    long int novi[n];

    for(int neki = 0;neki < k-1; neki++){
        for(int i = n-d; i < n; i++){
            novi[i] = Repi[i];
        }
        for(int i = n-d-1; i >= 0;i--){
            novi[i] = max(novi[i+1],Repi[i]+zadni_dan[i+d]);
        }
        for(int i = 0; i < n ; i++){
            zadni_dan[i] = novi[i];
        }
    }

    cout << zadni_dan[0] << std::endl;


    return 0;
}