1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <algorithm>
#include <iostream>

using namespace std;

int P[500005];
int D[500005];
int C[500005];
int NC[500005];

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    int x, d, h, m;
    cin >> x >> d >> h >> m;
    int m1 = 1440 * d + 60 * h + m;
    int m2 = 1440 * 25 + 1440 * (x - (x == 5 ? 0 : 1));
    int res = m2 - m1;
    if (x == 5 && 1440 * d + h * 60 + m < 1440 * 29 + 2 * 60) res -= 60;
    cout << res << "\n";
    cout.flush();
    return 0;
}