1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>

using namespace std;

// Funkcja obliczająca rzeczywistą liczbę minut od 23 marca od 00:00
int get_minutes(int d, int h, int m) {
    int total_minutes = (d - 23) * 24 * 60 + h * 60 + m;
    
    // Jeżeli jesteśmy po zmianie czasu (czyli po 29 marca, 3:00 w nocy)
    if (d > 29 || (d == 29 && h >= 3)) {
        total_minutes -= 60; // odejmujemy utraconą godzinę
    }
    
    return total_minutes;
}

int main() {
    // Optymalizacja wejścia/wyjścia
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int x, d, h, m;
    if (cin >> x >> d >> h >> m) {
        int end_d = 0;
        
        // Przypisujemy dzień końca dla danej rundy (00:00 następnego dnia)
        if (x == 1) end_d = 25;
        else if (x == 2) end_d = 26;
        else if (x == 3) end_d = 27;
        else if (x == 4) end_d = 28;
        else if (x == 5) end_d = 30;
        
        // Obliczamy ile minut od punktu startowego do końca rundy
        int end_time = get_minutes(end_d, 0, 0);
        int start_time = get_minutes(d, h, m);
        
        // Czas na zrobienie zadania to różnica pomiędzy końcem a startem
        cout << end_time - start_time << "\n";
    }
    
    return 0;
}