31752023-02-21 13:51:56TuruTamasSzurikáta (45)cpp17Időlimit túllépés 10/45375ms4836 KiB
#include <bits/stdc++.h>

using namespace std;

int N, P, Q;
vector<pair<int, int>> X;
vector<double> maxslopes;

void  getGood(vector<double>& v) {
    double cmax = v[0];
    maxslopes.push_back(cmax);
    for (size_t i = 1; i < v.size(); i++)
    {
        cmax = max(v[i], cmax);
        maxslopes.push_back(cmax);
    }
}

int doCrap(vector<double>& slope) {
    double maxslope = slope[0];
    int count = 1;
    for (size_t i = 1; i < slope.size(); i++)
    {
        if (slope[i] > maxslope) {
            count++;
            maxslope = slope[i];
        }
    }
    return count;
}

int main() {
    cin >> N >> P >> Q;
    int x;
    vector<double> slope;
    cout.precision(17);
    X.assign(N, {0, 0});
    for (size_t i = 0; i < N; i++)
    {
        cin >> x;
        X[i].first = x;
    }
    
    for (size_t i = 0; i < N; i++)
    {
        cin >> x;
        X[i].second = x;
        slope.push_back((double)((double)(x-P)/(double)X[i].first));
    }
    getGood(slope);
    vector<double> slope2 = slope;
    for (size_t q = 0; q < Q; q++)
    {
        int Db; cin >> Db;
        vector<pair<int, int>> kkckm;   
        int a, b;
        for (size_t i = 0; i < Db; i++)
        {
            cin >> a >> b;
            a--;
            double newslope = (double)((double)(X[a].second+b-P)/(double)X[a].first);
            if (newslope < maxslopes[a]) {
                continue;
            }
            kkckm.push_back({a, b});
            slope2[a] = newslope;
        }
        cout << doCrap(slope2) << ' ';
        for (pair<int, int>& x : kkckm)
        {
            slope2[x.first] = slope[x.first];
        }
        
    }
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base10/45
1Elfogadva0/03ms1808 KiB
2Elfogadva0/025ms2228 KiB
3Elfogadva2/24ms2340 KiB
4Elfogadva2/24ms2432 KiB
5Elfogadva2/210ms2804 KiB
6Elfogadva2/219ms2884 KiB
7Elfogadva2/218ms3228 KiB
8Időlimit túllépés0/4361ms3128 KiB
9Időlimit túllépés0/4331ms4836 KiB
10Időlimit túllépés0/4356ms3468 KiB
11Időlimit túllépés0/4375ms3504 KiB
12Időlimit túllépés0/4365ms3784 KiB
13Időlimit túllépés0/5363ms3872 KiB
14Időlimit túllépés0/5375ms3876 KiB
15Időlimit túllépés0/5356ms3864 KiB