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
#include <bits/stdc++.h>
using namespace std;
int x, d, h, m,e;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>x>>d>>h>>m;
    if (x <= 4)
    {
        e= 23 + x;
    }
    else
    {
        e= 29;
    }

    int start = (d - 23) * 24 * 60 + h * 60 + m;
    int kon = (e - 23) * 24 * 60 + 23 * 60 + 59 +1;
    int r = kon - start;
    int zm = (29 - 23) * 24 * 60 + 2 * 60 + 0;

    if (start < zm && kon > zm)
    {
        r -= 60;
    }
    cout<<r;
    return 0;
}