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
#include<bits/stdc++.h>

using namespace std;

signed main(){

cin.tie(0) -> sync_with_stdio(0);

int x,d,g,m;
cin>>x>>d>>g>>m;

x --;

vector<int> v = {24, 25, 26, 27, 29};

int ile = 0;

if(x == 4 && (d < 29 || g <= 2)){
    ile = -60;
}

if(d < v[x]){
    ile += 60-m;
    ile += (24-(g+1))*60;
    m = 0;
    g = 0;
    d ++;
}

if(d < v[x]){
    ile += 24*60;
}

ile += (23-g)*60;
ile += 60-m;

cout<<ile<<'\n';

}