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
#include <iostream>

using namespace std;
#define minInDay 1440;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int x, d, h, m, endsOn;
    cin >> x >> d >> h >> m;

    switch(x){
        case 1: endsOn = 24;
        break;
        case 2: endsOn = 25;
        break;
        case 3: endsOn = 26;
        break;
        case 4: endsOn = 27;
        break;
        case 5: endsOn = 29;
        break;
    }

    int mLeft = (25 - h) * 60 - 60 - m;
    mLeft += (endsOn - d) * minInDay;
    if(x == 5 && (d < 29 || h < 2)) mLeft -= 60;

    cout << mLeft;

    return 0;
}