Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 6/6 1,520 MiB 0,000 s OK
#2 6/6 1,477 MiB 0,000 s OK
#3 6/6 1,480 MiB 0,005 s OK
#4 6/6 1,516 MiB 0,000 s OK
#5 6/6 1,480 MiB 0,005 s OK
#6 7/7 1,477 MiB 0,000 s OK
#7 7/7 1,480 MiB 0,005 s OK
#8 7/7 1,520 MiB 0,000 s OK
#9 7/7 1,520 MiB 0,000 s OK
#10 7/7 1,477 MiB 0,000 s OK
#11 7/7 1,477 MiB 0,000 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,523 MiB 0,005 s OK
#15 7/7 1,484 MiB 0,005 s OK

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

struct skatla {
    int p[10];
};

int N = 0, D = 0;
struct skatla S[100];
int M[100];

static int compari(const int *a, const int *b) {
    return *b - *a;
}

static int compars(const struct skatla *a, const struct skatla *b) {
    int i = 0;
    for (; i < D; i++) {
        if (a->p[i] != b->p[i]) return b->p[i] - a->p[i];
    }
    return 0;
}

static int testfit(const struct skatla *a, const struct skatla *b) {
    int i = 0;
    for (; i < D; i++) {
        if (a->p[i] <= b->p[i]) return 0;
    }
    return 1;
}

int main() {
    int i = 0, j = 0, mm = 0;
    scanf("%d %d", &N, &D);
    for (; i < N; i++) {
        for (j = 0; j < D; j++) scanf("%d", &S[i].p[j]);
        qsort(S[i].p, D, sizeof(S[0].p[0]), (int (*)(const void *, const void *))compari);
    }
    qsort(S, N, sizeof(S[0]), (int (*)(const void *, const void *))compars);
    for (i = N - 1; i >= 0; i--) {
        int m = 0;
        for (j = N - 1; j > i; j--) {
            if (testfit(&S[i], &S[j]) == 1 && M[j] > m) m = M[j];
        }
        M[i] = m + 1;
        if (M[i] > mm) mm = M[i];
    }
    printf("%d\n", mm);
    return 0;
}