Rezultati

Up. imeNalogaJezikRezultatČas oddaje
FRISPI-2017 Škatle C 100/100OK 20. apr '17 @ 20:19

Test Točke Porabljen spomin Porabljen čas Status
#1 6/6 1,477 MiB 0,005 s OK
#2 6/6 1,520 MiB 0,005 s OK
#3 6/6 1,520 MiB 0,005 s OK
#4 6/6 1,516 MiB 0,005 s OK
#5 6/6 1,480 MiB 0,005 s OK
#6 7/7 1,480 MiB 0,000 s OK
#7 7/7 1,520 MiB 0,005 s OK
#8 7/7 1,484 MiB 0,005 s OK
#9 7/7 1,523 MiB 0,005 s OK
#10 7/7 1,520 MiB 0,005 s OK
#11 7/7 1,520 MiB 0,005 s OK
#12 7/7 1,484 MiB 0,005 s OK
#13 7/7 1,480 MiB 0,005 s OK
#14 7/7 1,484 MiB 0,005 s OK
#15 7/7 1,480 MiB 0,005 s OK

Ocenjevani program (skatla.c):

#include <stdio.h>


int st_skatel(int trenutna, int N, int D);
int gre_v_skatlo(int i, int j, int D);
void sort(int a[], int D);

int skatle[100][10];
int v[100];

int main()  {
    int N,D;
    
    for(int i = 0; i < 100; i++)    {
        v[i] = -1;
    }
    
    scanf("%d %d", &N, &D);
    
    for(int i = 0; i < N; i++)  {
        for(int j = 0; j < D; j++)  {
            scanf("%d", &skatle[i][j]);
        }
        sort(skatle[i], D);
    }
    
    int m = 0;
    
    for(int i = 0; i < N; i++)  {
        int s = st_skatel(i, N, D);
        if(s > m)
            m = s;
    }
    
    printf("%d", m);
    
    return 0;
}


void sort(int a[], int D)   {
    for (int i = 0; i < D; i++) {
        for(int j = 0; j < D-1; j++)  {
            if(a[j] < a[j+1])   {
                int zac = a[j+1];
                a[j+1] = a[j];
                a[j] = zac;
            }
        }
    }
}

int gre_v_skatlo(int i, int j, int D)    {
    for(int r = 0; r < D; r++)  {
        if(skatle[i][r] <= skatle[j][r])
            return 0;
    }
    return 1;
}

int st_skatel(int trenutna, int N, int D) {
    if(v[trenutna] != -1)
        return v[trenutna];
    int max = 0,s;
    for(int i = 0; i < N; i++)  {
        if(gre_v_skatlo(trenutna, i, D)) {
            if((s=st_skatel(i, N, D)) > max)
                max = s;
        }
    }
    v[trenutna] = max + 1;
    return max + 1;
}