37542023-03-02 19:55:28rennGladiátorok (40 pont)cpp17Elfogadva 40/4070ms13160 KiB
#include <bits/stdc++.h>
using namespace std;
#define GOTTAGOFAST cin.tie(0); cout.tie(0); ios::sync_with_stdio(0);

struct compar
{
    bool operator()(pair<long long,long long> &a, pair<long long,long long> &b)
    {
        if(a.first < b.first)
            return true;
        
        if(a.first > b.first)
            return false;
        
        return a.second > b.second;
    }
};

struct compar2
{
    bool operator()(pair<long long,int> &a, pair<long long,int> &b)
    {
        return a.first < b.first;
    }
};

int main()
{
    GOTTAGOFAST
    long long szen, glad;
    cin >> szen >> glad;

    vector< pair<long long, long long> > szenat(szen);
    vector< pair<long long, int> > gladiat(glad+1);
    vector<long long> prevglad(glad+1, 0);
    vector<int> gyozelmek(glad+1, 0);
    for(auto &x : szenat)
    {
        cin >> x.first >> x.second;
    }

    sort(szenat.begin(), szenat.end(), compar());

    for(int i = 1; i <= glad; i++)
    {
        cin >> gladiat[i].first;
        prevglad[i] = gladiat[i].first;
        gladiat[i].second = i;
    }
    gladiat[0].first = 0;
    gladiat[0].second = 0;

    sort(gladiat.begin(), gladiat.end(), compar2());

    /*for(auto &x : gladiat)
        cout << x.first << ":" << x.second << " ";
    cout << "\n";*/
    for(int i = 1, j = 0; i <= glad; i++)
    {
        //cout << (gladiat[i].first) << "-";
        gladiat[i].first += (gladiat[i-1].first-prevglad[gladiat[i-1].second]);
        //cout << gladiat[i].first << "\n";
        gyozelmek[gladiat[i].second] = gyozelmek[gladiat[i-1].second];
        for(; j < szen; j++)
        {
            //cout << gladiat[i].second << ":" << gladiat[i].first << " -> " << szenat[j].first << "\n";
            if(gladiat[i].first >= szenat[j].first)
            {
                gladiat[i].first += szenat[j].second;
                gyozelmek[gladiat[i].second]++;
                continue;
            }
            break;
        }
    }
    /*for(auto &x : gladiat)
        cout << x.first << ":" << x.second << " ";
    cout << "\n";*/

    for(int i = 1; i <= glad; i++)
        cout << gyozelmek[i] << " ";

    cout << "\n";
    return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base40/40
1Elfogadva0/03ms1988 KiB
2Elfogadva0/016ms4156 KiB
3Elfogadva2/23ms2304 KiB
4Elfogadva2/23ms2516 KiB
5Elfogadva2/24ms2984 KiB
6Elfogadva2/24ms3196 KiB
7Elfogadva2/24ms3408 KiB
8Elfogadva2/24ms3492 KiB
9Elfogadva2/24ms3756 KiB
10Elfogadva2/24ms3672 KiB
11Elfogadva2/212ms4748 KiB
12Elfogadva2/250ms9412 KiB
13Elfogadva2/250ms10884 KiB
14Elfogadva2/268ms12468 KiB
15Elfogadva2/268ms12664 KiB
16Elfogadva2/270ms12844 KiB
17Elfogadva2/268ms12892 KiB
18Elfogadva2/259ms12856 KiB
19Elfogadva2/259ms12852 KiB
20Elfogadva2/261ms12948 KiB
21Elfogadva2/263ms13160 KiB
22Elfogadva2/264ms13068 KiB