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
53
54
55
56
57
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
    
ll a,b,c,d;
cin>>a>>b>>c>>d;

vector<pair<ll,ll>>dni(4);
dni[0].first = 23;
dni[0].second = 24;

dni[1].first = 24;
dni[1].second = 25;

dni[2].first = 25;
dni[2].second = 26;

dni[3].first = 26;
dni[3].second = 27;

if(a != 5){
    if(b == dni[a-1].first){
        cout<<24*60+(24*60-c*60-d);
        return 0;
    }
    else{
        cout<<24*60 - 60*c - d;
        return 0;
    }
}
else{
    if(b<=28 || (b == 29 && c < 2)){
        if(b==27){
            cout<<71*60-60*c-d;
                return 0;
        }
        if(b==28){
            cout<<47*60-c*60-d;
                return 0;
        }
        if(b==29){
            cout<<21*60+(2*60-c*60-d);
                return 0;
        }
    }
    else{
        cout<<24*60-c*60-d;
        return 0;
    }
}
cout<<0;
    return 0;
}