1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int c[] = {0, 24, 25, 26, 27, 29};
    int x, d, h, m, res;

    cin >> x >> d >> h >> m;

    res = (c[x]-d)*24*60 + (23-h)*60 + (60-m);
    if (x==5 && (d<29 || h<2)) {
        res -= 60;
    }

    cout << res;

    return 0;
}