/* ID: espr1t TASK: KEYWORDS: CONTEST: CodeIT Round 4 */ #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; FILE *in; FILE *out; const int MAX = 1024; void fixTime(int& h, int& m, char t) { h %= 12; if (t == 'p') h += 12; } double getTime(int sh, int sm, int eh, int em) { if (sh == eh && sm == em) return 1; int ans = 0; // 23:52 - 02:56 -> 184 if (sh > eh || (sh == eh && sm > em)) { ans += (24 - (sh - eh)) * 60; } else { ans += (eh - sh) * 60; } // 15:59 - 16:01 -> 2 // 15:31 - 16:29 -> 58 if (sm <= em) { ans += em - sm; } else { ans -= sm - em; } return ans; } int main(void) { in = stdin; out = stdout; in = fopen("sunny.in", "rt"); out = fopen("sunny.out", "wt"); double ans = 0.0; int n; fscanf(in, "%d", &n); for (int i = 0; i < n; i++) { int sh, sm; char stm[32]; fscanf(in, "%d:%d %s", &sh, &sm, stm); int eh, em; char etm[32]; fscanf(in, "%d:%d %s", &eh, &em, etm); double u; fscanf(in, "%lf", &u); fixTime(sh, sm, stm[0]); fixTime(eh, em, etm[0]); // fprintf(stderr, "%02d:%02d to %02d:%02d (%lf minutes) for %lf\n", sh, sm, eh, em, getTime(sh, sm, eh, em), u); ans += getTime(sh, sm, eh, em) / 1440.0 * 24.0 * u * sqrt(u); } fprintf(out, "%.3lf\n", ans); return 0; }