86312024-01-24 09:47:47MagyarKendeSZLGTűzijátékcpp17Accepted 50/5017ms5924 KiB

#include <bits/stdc++.h>

#pragma region Utility

#define speed cin.tie(0); ios::sync_with_stdio(0)
#define cinv(v) for (auto& e : v) cin >> e;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define size(v) (int)v.size()
#define has(s, e) s.count(e)

#define max_index(v) max_element(all(v)) - v.begin()
#define min_index(v) min_element(all(v)) - v.begin()
#define smax(x, y) x = max(x, y)
#define smin(x, y) x = min(x, y)

#define sum(v) accumulate(all(v), 0)
#define product(v, T) accumulate(all(v), 1, multiplies<T>())

using namespace std;
using ll = long long;
using point = array<int, 2>;

int max(point p) { return max(p[0], p[1]); }
int min(point p) { return min(p[0], p[1]); }

template <typename T>
vector<T> prefix_sum(const vector<T>& v) {
    vector<T> result(size(v));
    partial_sum(all(v), result.begin());
    return result;
}

#pragma endregion


int main() {
    #ifdef ONLINE_JUDGE
    speed;
    #else
    #define cin fin
    ifstream fin("input.txt");
    #endif

    int N, S, T;
    cin >> N >> S >> T;
    vector<int> input(N + 1);
    for (int i = 1; i <= N; i++) cin >> input[i];
    vector<int> result({S});
    int left = S, right = S;
    for (int i = S; i <= N; i++) {
        if (abs(input[right] - input[i]) >= T) {
            result.push_back(i);
            right = i;
        }
    }
    for (int i = S; i > 0; i--) {
        if (abs(input[left] - input[i]) >= T) {
            result.push_back(i);
            left = i;
        }
    }
    sort(all(result));
    cout << size(result) << '\n';
    for (int x : result) cout << x << ' ';
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1832 KiB
2Accepted0/017ms3940 KiB
3Accepted2/23ms3060 KiB
4Accepted2/23ms3272 KiB
5Accepted2/23ms3508 KiB
6Accepted2/23ms3576 KiB
7Accepted2/23ms3556 KiB
8Accepted2/23ms3784 KiB
9Accepted2/23ms4188 KiB
10Accepted2/24ms4240 KiB
11Accepted2/24ms4412 KiB
12Accepted2/24ms4492 KiB
13Accepted2/24ms4652 KiB
14Accepted2/24ms4856 KiB
15Accepted3/34ms4872 KiB
16Accepted3/37ms5264 KiB
17Accepted3/38ms5196 KiB
18Accepted3/38ms5248 KiB
19Accepted3/317ms5872 KiB
20Accepted3/317ms5920 KiB
21Accepted4/417ms5924 KiB
22Accepted4/416ms5880 KiB