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
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using lld= long double;
#define v vector
#define pb  push_back
#define FF first
#define SS second

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll runda, dzien, godz, min;
    cin>>runda>>dzien>>godz>>min;
    const ll dz = dzien,  h = godz;
    min += 60 * godz;
    min += 24 * 60 * dzien;
    min -= 23 * 24 * 60;
    for(ll i=1;i<runda;i++){
        min -= 60 * 24;
    }
    ll ans = 24 * 60 * 2 - min;
    if(runda == 5){
        ans += 23 * 60;
    }
    if(runda == 5 && dz == 29 && 3 <= h) ans += 60;
    cout<<ans;
}