86312024-01-24 09:47:47MagyarKendeSZLGTűzijátékcpp17Elfogadva 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 << ' ';
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/03ms1832 KiB
2Elfogadva0/017ms3940 KiB
3Elfogadva2/23ms3060 KiB
4Elfogadva2/23ms3272 KiB
5Elfogadva2/23ms3508 KiB
6Elfogadva2/23ms3576 KiB
7Elfogadva2/23ms3556 KiB
8Elfogadva2/23ms3784 KiB
9Elfogadva2/23ms4188 KiB
10Elfogadva2/24ms4240 KiB
11Elfogadva2/24ms4412 KiB
12Elfogadva2/24ms4492 KiB
13Elfogadva2/24ms4652 KiB
14Elfogadva2/24ms4856 KiB
15Elfogadva3/34ms4872 KiB
16Elfogadva3/37ms5264 KiB
17Elfogadva3/38ms5196 KiB
18Elfogadva3/38ms5248 KiB
19Elfogadva3/317ms5872 KiB
20Elfogadva3/317ms5920 KiB
21Elfogadva4/417ms5924 KiB
22Elfogadva4/416ms5880 KiB