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

using namespace std;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);

	//runda, dzien, godzina, minuta
	int x, d, h, m;
	cin >> x >> d >> h >> m;

	//1-4: 2160
	//5:  pref: 2280
	//    suff: 1260

	int day = 24 * 60;
	int half_day = day / 2;
	int curr{};

	int res{};

	if (x < 5)//1-4
	{
		if (d - x == 22) //1 dzien
		{
			curr = h * 60 + m;
			res = day - curr + day;
		}
		else
		{
			curr = h * 60 + m;
			res = day - curr;
		}
	}
	else //5
	{
		if (d == 27)
		{
			curr = h * 60 + m;
			res = day - curr + day + day - 60;
		}
		else if (d == 28)
		{
			curr = h * 60 + m;
			res = day - curr + day - 60;
		}
		else if (d == 29)
		{
			if (h > 2)//po
			{
				curr = h * 60 + m;
				res = day - curr;
			}
			else
			{
				curr = h * 60 + m;
				res = 120 - curr + 21 * 60;
			}
		}
	}

	cout << res;
}