結果

問題 No.2803 Bocching Star
ユーザー srjywrdnprkt
提出日時 2024-10-20 22:53:17
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 672 bytes
コンパイル時間 2,342 ms
コンパイル使用メモリ 206,000 KB
最終ジャッジ日時 2025-02-24 22:04:01
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    ll N, S, P;
    cin >> N >> S;
    vector<ll> v;
    vector<pair<ll, ll>> w(N+2);
    w[0] = {-1e18, 0};
    w[N+1] = {1e18, N+1};
    for (int i=1; i<=N; i++){
        cin >> P;
        w[i] = {P, i};
    }
    sort(w.begin(), w.end());
    for (int i=1; i<=N; i++){
        if (w[i].first-w[i-1].first>S && w[i+1].first-w[i].first>S){
            v.push_back(w[i].second);
        }
    }
    sort(v.begin(), v.end());
    cout << v.size() << endl;
    for (auto x : v) cout << x << " ";
    cout << endl;

    return 0;
}
0