[Solved] how to change this code to be able to solve this challenge?


I’ve got AC with the following code

Code:

#include <stdio.h>

int main()
{
    int s, c, day = 0, z, cp, cb, m;
    int f[480], beg, max;
    int h1, m1, h2, m2;
    int p1, p2;
    char line[256];

    while (scanf("%d\n", &s) != EOF) {
    ++day;

    for (z = 0; z < 480; ++z) f[z] = 1;
    beg = 0;
    max = 0;

    for (c = 0; c < s; ++c) {
        scanf("%d:%d %d:%d", &h1, &m1, &h2, &m2);
        fgets(line, 256, stdin);

        p1 = (h1 - 10) * 60 + m1;
        p2 = (h2 - 10) * 60 + m2;
        for (cp = p1; cp < p2; ++cp) f[cp] = 0;
    }

    c = 0;
    while (c < 480) {
        if (f[c]) {
        cb = c;
        m = 0;
        while (f[c] && c < 480) {
            ++c;
            ++m;
        }
        if (m > max) {
            beg = cb;
            max = m;
        }
        } else {
        ++c;
        }
    }

    printf("Day #%d: the longest nap starts at %02d:%02d and will last for ", day, 10 + beg / 60, beg % 60);
    if (max > 59) printf("%d hours and ", max / 60);
    printf("%d minutes.\n", max % 60);
    }

    return 0;
}

solved how to change this code to be able to solve this challenge?