結果

問題 No.2803 Bocching Star
ユーザー eve__fuyukieve__fuyuki
提出日時 2024-07-13 20:30:05
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 899 bytes
コンパイル時間 2,496 ms
コンパイル使用メモリ 208,656 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-13 20:30:13
合計ジャッジ時間 7,539 ms
ジャッジサーバーID
(参考情報)
judge5 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main(){
    int n, s;
    cin >> n >> s;
    vector<int> p(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    vector<int> a(n);
    iota(a.begin(), a.end(), 0);
    sort(a.begin(), a.end(), [&](int i, int j){
        return p[i] < p[j];
    });
    vector<int> ans;
    for(int i = 0; i < n; i++){
        bool is_bocchi = true;
        if(i > 0 && p[a[i]] - p[a[i - 1]] <= s){
            is_bocchi = false;
        }
        if(i < n - 1 && p[a[i + 1]] - p[a[i]] <= s){
            is_bocchi = false;
        }
        if(is_bocchi){
            ans.push_back(a[i]);
        }
    }
    sort(ans.begin(), ans.end());
    cout << ans.size() << "\n";
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i] + 1 << " ";
    }
    cout << "\n";
} 
0