#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL_DEBUG
#include "debug.h"
#else
#define debug(...)
#endif
#define endl '\n'
using ll = long long;

// max(0.3*x,x−⌊120*x*t/250*d⌋−50w)

const long long D = 150;
long long initial_scores[] = {750, 1250, 1500, 2000, 2500, 3000};
long long tourist_times[] = {4, 13, 19, 38, 65, 134};

void solve() {
    for (int i = 0; i < 6; i++) {
        long double x = initial_scores[i];
        long double t = tourist_times[i];
        int wa = 0; // tourist doesn't get WA
        long double tourist_score = max(0.3 * x, x - floor(120 * x * t / (250 * D)) - 50 * wa);
        cout << "In problem " << (char)('A' + i) << " tourist's score was " << tourist_score << ", solving it in " << t << " minutes" << endl;
        long long L = t + 1, R = 1e9;
        long double score_to_lose = tourist_score - 6;
        long double time_to_lose = 1e9;
        while (L <= R) {
            long double m = (L + R) / 2;
            long double possible_score = max(0.3 * x, x - floor(120 * x * m / (250 * D)) - 50 * wa);
            if (possible_score <= score_to_lose) {
                time_to_lose = m;
                R = m - 1;
            } else {
                L = m + 1;
            }
        }
        cout << "If tourist took " << (time_to_lose - t) << " minutes more, he would have lost the 1st place" << endl;
    }
}

int32_t main() {
    cin.tie(0)->sync_with_stdio(0);
    solve();
    /* cout << solve() << endl; */
    /* cout << (solve() ? "Yes" : "No") << endl; */
}
