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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <iostream>
#include <string>
#include <chrono>

using namespace std;

int x, d, h, m;

int main()
{
	cin >> x >> d >> h >> m;
	if (x == 1) {
		if (d == 23) {
			int res = (((24 - h) * 60) + (24 * 60)) - m;
			if (res <= 1) {
				res = 0;
			}
			cout << res;
		}
		else {
			int res = ((24 - h) * 60) - m;			
			cout << res;
		}
	}

	if (x == 2) {
		if (d == 24) {
			int res = (((24 - h) * 60) + (24 * 60)) - m;			
			cout << res;
		}
		else {
			int res = ((24 - h) * 60) - m;
			cout << res;
		}
	}

	if (x == 3) {
		if (d == 25) {
			int res = (((24 - h) * 60) + (24 * 60)) - m;			
			cout << res;
		}
		else {
			int res = ((24 - h) * 60) - m;			
			cout << res;
		}
	}

	if (x == 4) {
		if (d == 26) {
			int res = (((24 - h) * 60) + (24 * 60)) - m;		
			cout << res;
		}
		else {
			int res = ((24 - h) * 60) - m;			
			cout << res;
		}
	}

	if (x == 5) {
		if (d == 27) {
			int res = ((24 - h) * 60) + ((24 - h) * 60) + (24 * 60) - m - 60;			
			cout << res;
		} if (d == 28) {
			int res = (((24 - h) * 60) + (24 * 60)) - m - 60;			
			cout << res;
		}
		else if(d== 29){
			if (h < 2) {
				int res = ((24 - h) * 60) - m - 60;
				cout << res;
			}
			else {
				int res = ((24 - h) * 60) - m;
				cout << res;
			}
		}
	}
	return 0;
}