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
// PA 2024 1C - Finalisci
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	long long x, d, h, m;
	long long roundEnd, currTime, skipTime;
	
	cin >> x;
	if (x == 5) {
		++x;
	}
	cin >> d;
	cin >> h;
	cin >> m;
	
	roundEnd = (x + 1) * 24 * 60;
	currTime = ((d - 23) * 24 + h) * 60 + m;
	skipTime = (6 * 24 + 2) * 60;
	
	if (currTime <= skipTime && skipTime <= roundEnd) {
			cout << roundEnd - currTime - 60 << endl;
	} else {
			cout << roundEnd - currTime << endl;
	}	
	
	return 0;
}