1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	int d,h,m,x;
	vector<int>v;
	v.push_back(24);
	v.push_back(25);
	v.push_back(26);
	v.push_back(27);
	v.push_back(29);
	cin>>x>>d>>h>>m;
	x--;
	int wynik=(v[x]-d)*24*60+(24*60-h*60-m);
	if(x==4&&d*24*60+h*60+m<29*24*60+2*60){wynik-=60;}
	cout<<wynik;
    return 0;
}