43762023-03-27 11:22:13semmiTűzijátékcpp17Wrong answer 48/5016ms5404 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+1;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
base48/50
1Accepted0/03ms1832 KiB
2Accepted0/016ms3128 KiB
3Wrong answer0/23ms2232 KiB
4Accepted2/23ms2456 KiB
5Accepted2/23ms2676 KiB
6Accepted2/22ms2740 KiB
7Accepted2/23ms2868 KiB
8Accepted2/22ms2976 KiB
9Accepted2/23ms2992 KiB
10Accepted2/24ms3260 KiB
11Accepted2/24ms3216 KiB
12Accepted2/24ms3512 KiB
13Accepted2/24ms3600 KiB
14Accepted2/24ms3464 KiB
15Accepted3/34ms3728 KiB
16Accepted3/36ms3872 KiB
17Accepted3/37ms4072 KiB
18Accepted3/38ms4424 KiB
19Accepted3/314ms5404 KiB
20Accepted3/316ms5320 KiB
21Accepted4/414ms5372 KiB
22Accepted4/414ms5020 KiB