17992022-12-03 19:02:15kdbUtazásszervezés (75 pont)cpp11Accepted 75/754ms4100 KiB
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n, m, k, c;
    cin >> n >> m >> k >> c;
    if (n >= c)
    {
        cout << c << endl;
        return 0;
    }
    vector<int> vec, vec2;
    for (size_t i = 0; i < c; i++)
    {
        int a;
        cin >> a;
        vec.push_back(a);
        if (i < n) vec2.push_back(a);
    }
    int j = 0, q = n;
    for (int i = n; i < c; i++)
    {
        if (vec[i] - k >= vec2[j])
        {
            vec2[j] = vec[i];
            j++;
            q++;
        }
        if (j == n) j = 0;
    }
    cout << q << endl;
    return 0;
}
/*
2 10 4 6
1 2 2 5 6 7
-4
*/
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1828 KiB
2Accepted0/04ms2552 KiB
3Accepted3/33ms2268 KiB
4Accepted4/43ms2528 KiB
5Accepted4/43ms2616 KiB
6Accepted4/42ms2744 KiB
7Accepted4/43ms3084 KiB
8Accepted4/43ms3144 KiB
9Accepted5/53ms3240 KiB
10Accepted5/53ms3336 KiB
11Accepted6/63ms3452 KiB
12Accepted6/63ms3500 KiB
13Accepted6/63ms3756 KiB
14Accepted6/64ms4016 KiB
15Accepted6/64ms4100 KiB
16Accepted6/64ms4096 KiB
17Accepted6/64ms4096 KiB