58932023-10-04 18:28:29gergomiszoriUtazásszervezés (75 pont)cpp11Accepted 75/756ms4316 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+2);

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

    for(int i = 1; i < k-m+2; 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/03ms1876 KiB
2Accepted0/06ms2384 KiB
3Accepted3/33ms2288 KiB
4Accepted4/43ms2472 KiB
5Accepted4/43ms2692 KiB
6Accepted4/43ms2904 KiB
7Accepted4/43ms3008 KiB
8Accepted4/43ms3024 KiB
9Accepted5/53ms3304 KiB
10Accepted5/53ms3548 KiB
11Accepted6/64ms3640 KiB
12Accepted6/64ms3868 KiB
13Accepted6/64ms4124 KiB
14Accepted6/64ms4140 KiB
15Accepted6/66ms4028 KiB
16Accepted6/66ms4312 KiB
17Accepted6/66ms4316 KiB