#include <iostream>
#include <map>
typedef struct taskDate {
int x;
int d;
int h;
int m;
};
typedef std::map<int, int> taskToDay;
void prog_main(std::istream& in, std::ostream& out)
{
taskToDay pub = {
{1, 23},
{2, 24},
{3, 25},
{4, 26},
{5, 27}
};
taskToDay sub = {
{1, 24},
{2, 25},
{3, 26},
{4, 27},
{5, 29}
};
taskDate start{};
in >> start.x;
in >> start.d;
in >> start.h;
in >> start.m;
taskDate end{start.x, sub[start.x], 23, 59};
int result = (end.d - start.d) * 24 * 60;
result += (end.h - start.h) * 60;
result += (end.m - start.m);
result += 1;
if (start.x == 5 ) {
if (start.d < 29 ||
(start.d == 29 && start.h <= 1) ||
(start.d == 29 && start.h == 2 && start.m == 0)) {
result -= 60;
}
}
out << result << std::endl;
}
#ifndef TEST
int main(int argc, char* argv[])
{
prog_main(std::cin, std::cout);
return 0;
}
#endif
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | #include <iostream> #include <map> typedef struct taskDate { int x; int d; int h; int m; }; typedef std::map<int, int> taskToDay; void prog_main(std::istream& in, std::ostream& out) { taskToDay pub = { {1, 23}, {2, 24}, {3, 25}, {4, 26}, {5, 27} }; taskToDay sub = { {1, 24}, {2, 25}, {3, 26}, {4, 27}, {5, 29} }; taskDate start{}; in >> start.x; in >> start.d; in >> start.h; in >> start.m; taskDate end{start.x, sub[start.x], 23, 59}; int result = (end.d - start.d) * 24 * 60; result += (end.h - start.h) * 60; result += (end.m - start.m); result += 1; if (start.x == 5 ) { if (start.d < 29 || (start.d == 29 && start.h <= 1) || (start.d == 29 && start.h == 2 && start.m == 0)) { result -= 60; } } out << result << std::endl; } #ifndef TEST int main(int argc, char* argv[]) { prog_main(std::cin, std::cout); return 0; } #endif |
English