18262022-12-04 14:22:50kdbTűzijátékcpp11Accepted 50/5014ms5080 KiB
#include <iostream>
#include <vector>
#include <map>
#include <deque>
using namespace std;
#define ll long long

ostream& operator<<(ostream& os, vector<int>& input)
{
    for (auto i : input)
    {
        os << i << " ";
    }
    return os;
}

int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n, s, t;
    cin >> n >> s >> t;
    vector<int>vec(n);
    deque<int>m;
    for (size_t i = 0; i < n; i++) cin >> vec[i];
    int a = vec[s - 1];
    m.push_back(s);
    for (int i = s-1; i >= 0; i--)
    {
        if (i>=0 && a - t >= vec[i])
        {
            a = vec[i];
            m.push_front(i + 1);
        }
    }
    a = vec[s - 1];
    for (size_t i = s; i < n; i++)
    {
        if (a + t <= vec[i])
        {
            a = vec[i];
            m.push_back(i + 1);
        }
    }
    cout << m.size() << endl;
    while (!m.empty())
    {
        cout << m.front() << " ";
        m.pop_front();
    }
    cout << endl;
    return 0;
}
/*
6 4 100
0 70 110 210 230 500
*/
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1828 KiB
2Accepted0/014ms2872 KiB
3Accepted2/22ms2096 KiB
4Accepted2/22ms2332 KiB
5Accepted2/22ms2448 KiB
6Accepted2/22ms2660 KiB
7Accepted2/22ms2860 KiB
8Accepted2/22ms3088 KiB
9Accepted2/23ms3188 KiB
10Accepted2/23ms3260 KiB
11Accepted2/23ms3264 KiB
12Accepted2/24ms3476 KiB
13Accepted2/24ms3424 KiB
14Accepted2/24ms3680 KiB
15Accepted3/34ms3664 KiB
16Accepted3/36ms3916 KiB
17Accepted3/37ms3892 KiB
18Accepted3/38ms4156 KiB
19Accepted3/314ms4872 KiB
20Accepted3/314ms4928 KiB
21Accepted4/414ms5080 KiB
22Accepted4/414ms5024 KiB