#include #include #include int main() { int days; std::cin >> days; int sleep_time = 0; for (int i = 0; i < days; i++) { std::string sleep, wakeup; std::cin >> sleep >> wakeup; int it = sleep.find(':', 0); std::string sleep_hour = sleep.substr(0, it); sleep.erase(0, it + 1); it = wakeup.find(':', 0); std::string wakeup_hour = wakeup.substr(0, it); wakeup.erase(0, it + 1); int sleeph = std::stoi(sleep_hour); int sleepm = std::stoi(sleep); int wakeuph = std::stoi(wakeup_hour); int wakeupm = std::stoi(wakeup); if (wakeupm < sleepm) { sleep_time += (wakeupm + 60 - sleepm); wakeuph--; } else { sleep_time += wakeupm - sleepm; } if(wakeuph < sleeph){ sleep_time += (wakeuph + 24 - sleeph) * 60; } else { sleep_time += (wakeuph - sleeph) * 60; } } std::cout << sleep_time << std::endl; return 0; }