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
#include<bits/stdc++.h>
using namespace std; 
constexpr int TIME = (24*2)*60;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int r, d, h, m;
    cin >> r >> d >> h >> m;
    if(r == 5) {
        if(d == 27) {
            cout<<2*24*60 + 23*60 - h*60 - m; 
        }
        else if(d == 28) {
            cout<<24*60 + 23*60 - h*60 - m;
        }
        else if(d == 29) {
            if(h > 2)
                cout<<24*60 - h*60 - m;
            else 
                cout<<23*60 - h*60 - m;
        }
        return 0;
    }
    d = d - 22 - r;
    if(d == 0) {
        cout<<2*24*60 - h*60 - m;
    }
    else {
        cout<<24*60 - h*60 - m;
    }
}