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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);

  int x,d,h,m;

  cin >> x >> d >> h >> m;
  int result = 2160;
  
  if(x == 1) {
    result -= (d - 23) * 1440 + (h - 12) * 60 + m;
  } else if(x == 2) {
    result -= (d - 24) * 1440 + (h - 12) * 60 + m;
  }  else if(x == 3) {
    result -= (d - 25) * 1440 + (h - 12) * 60 + m;
  } else if(x == 4) {
    result -= (d - 26) * 1440 + (h - 12) * 60 + m;
  } else if(x == 5) {
    result = 3600 - ((d - 27) * 1440 + (h - 12) * 60 + m);
    if (result > 1260) {
      result -= 60;
    }
  }

  cout << result << endl;
}