114702024-10-04 09:26:06madvirTűzijátékcpp11Accepted 50/5048ms2200 KiB
#include <iostream>
#include <set>
#include <iterator>

using namespace std;

int main()
{
    int n, s, t;
    cin >> n >> s >> t;
    int a[n+1];
    set<int> index;

    for(int i=1; i<=n; i++) {
        cin >> a[i];
    }

    int f, x;

    index.insert(s);

    ///stol vissza !!!!
    f=s-1;
    x=a[s];
    while(f>=1) {
        if(x-a[f]>=t) {
            x=a[f];
            index.insert(f);
        }
        f--;
    }

    ///stol elore
    f=s+1;
    x=a[s];
    while(f<=n) {
        if(a[f]-x>=t) {
            x=a[f];
            index.insert(f);
        }
        f++;
    }

    cout << index.size() << endl;

    set<int>::iterator ptr;

    for(ptr=index.begin(); ptr!=index.end(); ptr++) {
        cout << *ptr << " ";
    }


    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms360 KiB
2Accepted0/046ms2024 KiB
3Accepted2/23ms488 KiB
4Accepted2/22ms360 KiB
5Accepted2/23ms756 KiB
6Accepted2/23ms504 KiB
7Accepted2/23ms504 KiB
8Accepted2/22ms360 KiB
9Accepted2/24ms528 KiB
10Accepted2/27ms560 KiB
11Accepted2/26ms428 KiB
12Accepted2/29ms616 KiB
13Accepted2/29ms760 KiB
14Accepted2/29ms888 KiB
15Accepted3/39ms784 KiB
16Accepted3/314ms760 KiB
17Accepted3/318ms944 KiB
18Accepted3/321ms1240 KiB
19Accepted3/348ms2148 KiB
20Accepted3/346ms2200 KiB
21Accepted4/446ms2024 KiB
22Accepted4/445ms1768 KiB