43772023-03-27 11:24:04semmiTűzijátékcpp17Accepted 50/5016ms4732 KiB
#include <bits/stdc++.h>

using namespace std;




int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, t, d;
    cin >> n >> t >> d;
    
    
    vector<int> k(n);
    for(int i = 0;i < n;i++ ) cin >> k[i];
    int previ = k[t-1];
    
    int ans = 1;
    
    vector<int> ansok;
    ansok.push_back(t);
    for(int i = t-2;i>=0;i--) {
        if(k[i] + d <= previ) {
            previ = k[i];
            ans++;
            ansok.push_back(i+1);
        }
    }
    previ = k[t-1];
    for(int i = t;i<n;i++ ) {
        if(k[i] - d >= previ) {
            previ = k[i];
            ans++;
            ansok.push_back(i+1);
        }   
    }
    
    sort(ansok.begin(), ansok.end());
    cout << ans << endl;
    for(int i = 0;i < ansok.size();i++ ) {
        cout << ansok[i] << ' ';
    }
    
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1700 KiB
2Accepted0/016ms3036 KiB
3Accepted2/23ms2076 KiB
4Accepted2/23ms2304 KiB
5Accepted2/23ms2500 KiB
6Accepted2/23ms2740 KiB
7Accepted2/22ms2652 KiB
8Accepted2/23ms2884 KiB
9Accepted2/23ms2924 KiB
10Accepted2/24ms3248 KiB
11Accepted2/24ms3456 KiB
12Accepted2/24ms3500 KiB
13Accepted2/24ms3628 KiB
14Accepted2/24ms3744 KiB
15Accepted3/34ms3572 KiB
16Accepted3/36ms3768 KiB
17Accepted3/38ms3652 KiB
18Accepted3/38ms4064 KiB
19Accepted3/316ms4680 KiB
20Accepted3/316ms4688 KiB
21Accepted4/416ms4732 KiB
22Accepted4/414ms4440 KiB