結果

問題 No.2803 Bocching Star
ユーザー Kou0406
提出日時 2024-07-19 12:50:37
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 779 bytes
コンパイル時間 4,041 ms
コンパイル使用メモリ 112,688 KB
実行使用メモリ 6,604 KB
最終ジャッジ日時 2024-07-19 12:50:46
合計ジャッジ時間 8,876 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;

typedef pair<int,int> p;

int n,s;

int main(){
    int i,j;
    vector<p> a;
    vector<int> ans;
    scanf("%d%d",&n,&s);
    rep(i,n){
        scanf("%d",&j);
        a.push_back(p(j,i+1));
    }
    sort(a.begin(),a.end());
    rep(i,n){
        if(i-1>=0&&abs(a[i-1].first-a[i].first)<=s)
            continue;
        if(i+1<n&&abs(a[i+1].first-a[i].first)<=s)
            continue;
        ans.push_back(a[i].second);
    }
    printf("%d\n",(int)ans.size());
    if(ans.size()){
        sort(ans.begin(),ans.end());
        rep(i,ans.size()-1)
            printf("%d ",ans[i]);
        printf("%d\n",ans[i]);
    }
    return 0;
}
0