58902023-10-04 18:18:15gergomiszoriUtazásszervezés (75 pont)cpp11Accepted 75/756ms3948 KiB
#include <bits/stdc++.h>

using namespace std;

int tel;
int n, k, m, c;
int ind;
vector<int> igenyek;
vector<int> veg;

int main()
{
    cin >> n >> k >> m >> c;
    igenyek.resize(c);
    veg.resize(k+1);

    for(int i = 0; i < c; i++) cin >> igenyek[i];

    for(int i = 1; i < k+1; i++)
    {
        if(ind == igenyek.size())
            break;
        n += veg[i];
        while(ind < igenyek.size() && igenyek[ind] < i) ind++;
        int tempn = n;
        for(int j = 0; j < tempn; j++)
        {
            if(igenyek[ind] == i)
            {
                ind++; tel++; n--; veg[i+m] += 1;
                if(ind == igenyek.size())
                    break;
            }
            else
                break;
        }
    }


    cout << tel;


    return 0;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1772 KiB
2Accepted0/06ms2240 KiB
3Accepted3/33ms2208 KiB
4Accepted4/43ms2452 KiB
5Accepted4/42ms2536 KiB
6Accepted4/42ms2500 KiB
7Accepted4/43ms2644 KiB
8Accepted4/43ms3060 KiB
9Accepted5/53ms3276 KiB
10Accepted5/53ms3472 KiB
11Accepted6/64ms3428 KiB
12Accepted6/66ms3736 KiB
13Accepted6/64ms3744 KiB
14Accepted6/66ms3876 KiB
15Accepted6/66ms3692 KiB
16Accepted6/66ms3948 KiB
17Accepted6/66ms3912 KiB