#include #define rep(i, ss, ee) for (int i = ss; i < ee; ++i) using namespace std; std::vector split_int(std::string src, char delimiter) { int first = 0; int last = src.find_first_of(delimiter); std::vector result; while (first < src.size()) { std::string subStr(src, first, last - first); result.emplace_back(std::stoi(subStr)); first = last + 1; last = src.find_first_of(delimiter, first); if (last == std::string::npos) { last = src.size(); } } return result; } int main() { int N; int ans = 0; string s; cin >> N; vector vs, ve; int ts, te; const int h24 = 24 * 60; rep(i, 0, N) { cin >> s; vs = split_int(s, ':'); cin >> s; ve = split_int(s, ':'); ts = vs[0] * 60 + vs[1]; te = ve[0] * 60 + ve[1]; if (ts > te) { te += h24; } ans += te - ts; } cout << ans << endl; getchar(); }