21062022-12-20 07:28:32szabel26Tűzijátékcpp17Accepted 50/5045ms5500 KiB
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>

using namespace std;

deque<int>v;
vector<int>telepules;
vector<int>helyek;

int i,n,s,t,db=1;

int main()
{
    cin>>n>>s>>t;
    telepules.resize(n+1);
    for(i=1;i<=n;++i) cin>>telepules[i];

    v.push_back(telepules[s]);
    for(i=s-1;i>=1;--i)
    {
        if(v[0]-telepules[i]>=t){
            v.push_back(telepules[i]);
            helyek.push_back(i);
            v.pop_front();
            ++db;
        }
    }
    v.pop_front();
    v.push_back(telepules[s]);
    helyek.push_back(s);
    for(i=s+1;i<=n;++i)
    {
        if(telepules[i]-v[0]>=t){
            v.push_back(telepules[i]);
            helyek.push_back(i);
            v.pop_front();
            ++db;
        }
    }
    sort(helyek.begin(),helyek.end());

    cout<<db<<"\n";
    for (auto &e:helyek) cout<<e<<" ";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1688 KiB
2Accepted0/045ms2824 KiB
3Accepted2/22ms2052 KiB
4Accepted2/22ms2168 KiB
5Accepted2/22ms2256 KiB
6Accepted2/22ms2332 KiB
7Accepted2/22ms2604 KiB
8Accepted2/22ms2768 KiB
9Accepted2/24ms2908 KiB
10Accepted2/24ms3252 KiB
11Accepted2/26ms3456 KiB
12Accepted2/28ms3700 KiB
13Accepted2/28ms3732 KiB
14Accepted2/28ms3980 KiB
15Accepted3/38ms4192 KiB
16Accepted3/313ms4220 KiB
17Accepted3/317ms4392 KiB
18Accepted3/320ms4872 KiB
19Accepted3/345ms5500 KiB
20Accepted3/343ms5456 KiB
21Accepted4/443ms5216 KiB
22Accepted4/443ms5076 KiB