88602024-02-02 16:17:00zeytonxTűzijátékcpp17Accepted 50/5017ms10736 KiB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define endl "\n"
#define pll pair<ll,ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define fs first
#define sc second

const ll MOD = 1e9+7;

void solve()
{
	ll n, s, t;
	cin >> n >> s >> t;
	vector<ll> v(n);
	vector<ll> ans;
	for(ll i = 0; i < n; i++)
		cin >> v[i];
	ans.push_back(s-1);
	ll last_pos = s-1;
	for(ll i = s-1; i < n; i++)
	{
		if(last_pos != -1)
		{
			if(v[last_pos] + t <= v[i])
			{
				ans.push_back(i);
				last_pos = i;
			}
		}
	}
	last_pos = s-1;
	for(ll i = s-1; i >= 0; i--)
	{
		if(last_pos != -1)
		{
			if(v[last_pos] - t >= v[i])
			{
				ans.push_back(i);
				last_pos = i;
			}
		}
	}

	sort(ans.begin(), ans.end());
	cout << ans.size() << endl;
	for(ll i : ans)
		cout << i+1 << " ";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--)
        solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1824 KiB
2Accepted0/017ms4872 KiB
3Accepted2/23ms3048 KiB
4Accepted2/23ms3260 KiB
5Accepted2/23ms3480 KiB
6Accepted2/23ms3700 KiB
7Accepted2/23ms3672 KiB
8Accepted2/23ms3680 KiB
9Accepted2/23ms3964 KiB
10Accepted2/24ms4048 KiB
11Accepted2/24ms4268 KiB
12Accepted2/24ms4724 KiB
13Accepted2/24ms4736 KiB
14Accepted2/24ms4868 KiB
15Accepted3/34ms5144 KiB
16Accepted3/37ms5412 KiB
17Accepted3/38ms5988 KiB
18Accepted3/38ms6708 KiB
19Accepted3/317ms8732 KiB
20Accepted3/317ms9420 KiB
21Accepted4/417ms10420 KiB
22Accepted4/417ms10736 KiB