Rezultati

Up. imeNalogaJezikRezultatČas oddaje
finalsolution-2018 Priprava naloge C 100/100OK 19. apr '18 @ 16:40

Test Točke Porabljen spomin Porabljen čas Status
#1 11/11 2,250 MiB 0,095 s OK
#2 11/11 2,223 MiB 0,107 s OK
#3 11/11 2,250 MiB 0,095 s OK
#4 11/11 2,223 MiB 0,113 s OK
#5 11/11 2,250 MiB 0,110 s OK
#6 11/11 2,219 MiB 0,067 s OK
#7 11/11 1,492 MiB 0,005 s OK
#8 11/11 2,223 MiB 0,039 s OK
#9 12/12 1,340 MiB 0,000 s OK

Ocenjevani program (naloge.c):
#include <stdio.h>

int T[100000];
int C[100000];

int main() {
    int i = 0, j = 0, n = 0, k = 0;
    long long t = 0, c = 0, b = -1;
    scanf("%d %d", &k, &n);
    for (; i < n; i++) {
        scanf("%d %d", &T[i], &C[i]);
        c += C[i];
    }
    for (i = 0; i < n; i++) {
        while (t < k && j < n) {
            t += T[j];
            c -= C[j];
            j++;
        }
        if (t >= k && c > b) b = c;
        t -= T[i];
        c += C[i];
    }
    if (t >= k && c > b) b = c;
    if (b == -1) printf("Tekma bo polom\n");
    else printf("%lld\n", b);
    return 0;
}