1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <bits/stdc++.h> 
using namespace std;
int main() {
    int x,d,h,m,t;
    cin>>x>>d>>h>>m;
    t=(23-h)*60+(60-m);
    int dk=23+x;
    if(x==5)
    {
        dk++;
    }
    for (int i=d+1; i<=dk; i++)
     {
        t+=24*60;
    }
    if (x==5) 
    {
        if (d<29||(d==29&&h<2)) 
        {
            t-=60; 
        }
    }
    cout<<t;
}