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
#include <iostream>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int x, d, h, m;
    if (!(cin >> x >> d >> h >> m)) return 0;

    int endDay;
    if (x == 1) endDay = 25;
    else if (x == 2) endDay = 26;
    else if (x == 3) endDay = 27;
    else if (x == 4) endDay = 28;
    else endDay = 29+1;

    long long totalMinutes = (long long)(endDay - d) * 1440 - (h * 60 + m);

    if (x == 5) {
        if (d < 29 || (d == 29 && h < 2)) {
            totalMinutes -= 60;
        }
    }

    cout << totalMinutes << endl;

    return 0;
}