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
#include <bits/stdc++.h>
using namespace std;

// liczba dni do końca rund
int end_day[6] = {0, 24, 25, 26, 27, 29};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t, d, h, m;
    cin >> t >> d >> h >> m;

    int endD = end_day[t];

    // przelicz wszystko na minuty od początku miesiąca (1 marca 00:00)
    int start_minutes = (d - 1) * 24 * 60 + h * 60 + m;
    int end_minutes = (endD - 1) * 24 * 60 + 23 * 60 + 59;

    int result = end_minutes - start_minutes + 1;

    // zmiana czasu: 29 marca 02:00 → 03:00 (tracimy 60 minut)
    int change_time = (29 - 1) * 24 * 60 + 2 * 60;

    if (start_minutes < change_time && end_minutes >= change_time) {
        result -= 60;
    }

    cout << result << "\n";

    return 0;
}