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
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>

using namespace std;
int x,d,h,m,t=2160;
int main()
{
    cin >> x >> d >> h >> m;
    if(x!=5)
    {
        if(d-22-x==1)
        {
            t-=720;
            d++;
            //t-=(h-12)*60;
            //t-=m;
            //h=0;
            t-=h*60;
            t-=m;
        }
        else
        {
            t-=(h-12)*60;
            t-=m;
        }

    }
    else
    {
        t=3600;
        if(d!=27)
        {
            t-=720;
            //d--;
            t-=(d-28)*1440;
            t-=h*60;
            t-=m;
        }
        else
        {
            t-=(h-12)*60;
            t-=m;
        }
        if(d<29|h<2)
        {
            t-=60;
        }
        //t-=(d-27)*1440;

    }
    cout << t;
    return 0;
}