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
33
34
35
36
37
38
39
40
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
    int x, d, h, m;
    cin>> x >> d >> h >> m;
    if (x<5)
    {
        if (d-x==22)
        {
            cout<< (24-h)*60-m+1440;
        }
        else
        {
            cout<< (24-h)*60-m;
        }
    }
    else
    {
        if (d==27)
        {
            cout<< (24-h)*60-m+1440+1440-60;
        }
        if (d==28)
        {
            cout<< (24-h)*60-m+1440-60;
        }
        if (d==29)
        {
            if (h<3)
                cout<< (23-h)*60-m;
            else
                cout<< (24-h)*60-m;
        }
    }
    return 0;
}