Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.1 kB
5
Indexable
Never
#include <bits/stdc++.h>

using namespace std;

int main() {
    vector<string> schedule(7);
    for (int i = 0; i < 7; ++i) {
        cin >> schedule[i];
    }
    
    int d, h;
    cin >> d >> h;
    
    vector<pair<int, int>> days(7);
    for (int i = 0; i < 7; ++i) {
        days[i] = {count(schedule[i].begin(), schedule[i].end(), '.'), i};
    }
    
    sort(days.rbegin(), days.rend());
    
    vector<int> selected_days;
    for (int i = 0; i < d; ++i) {
        selected_days.push_back(days[i].second);
    }
    
    vector<int> hour_counts(24, 0);
    for (int hour = 0; hour < 24; ++hour) {
        for (int day : selected_days) {
            if (schedule[day][hour] == '.') {
                hour_counts[hour]++;
            }
        }
    }
    
    sort(hour_counts.rbegin(), hour_counts.rend());
    
    int available_slots = 0;
    for (int i = 0; i < h; ++i) {
        available_slots += hour_counts[i];
    }
    
    double probability = static_cast<double>(available_slots) / (d * h);
    
    cout << fixed << setprecision(12) << probability << endl;
    
    return 0;
}
Leave a Comment