1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <bits/stdc++.h>
using namespace std;
int main() {
    int x, d, h, m;
    cin >> x >> d >> h >> m;
    auto convert = [&](int d, int h, int m) {
        int ret = (d - 23) * 60 * 24 + h * 60 + m;
        if (d >= 29) {
            if (h >= 3 || d > 29) {
                ret -= 60;
            }
        }
        return ret;
    };
    int end_d;
    if (x == 1) end_d = 24;
    else if (x == 2) end_d = 25;
    else if (x == 3) end_d = 26;
    else if (x == 4) end_d = 27;
    else end_d = 29;
    cout << convert(end_d + 1, 0, 0) - convert(d, h, m) << '\n';
}