結果

問題 No.2803 Bocching Star
ユーザー daiota
提出日時 2024-07-12 23:58:02
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 844 bytes
コンパイル時間 1,771 ms
コンパイル使用メモリ 177,044 KB
実行使用メモリ 6,016 KB
最終ジャッジ日時 2024-07-12 23:58:07
合計ジャッジ時間 4,910 ms
ジャッジサーバーID
(参考情報)
judge6 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define REP(i,n) for(int i=0;i<int(n);i++)







int main(void){
	cin.tie(nullptr);  ios_base::sync_with_stdio(false);
	int i,j;

	int N,S;
	cin >> N >> S;

	if(N==1){
		cout << 1 << endl;
		cout << 1 << endl;
		return 0;
	}

	vector<P> v(N);
	REP(i,N){
		cin >> v[i].first;
		v[i].second=i+1;
	}

	sort(v.begin(),v.end());


	vector<int> a;
	REP(i,N){
		if(i==0){
			if(v[1].first-v[0].first>S) a.push_back(v[0].second);
		}
		else if(i==N-1){
			if(v[N-1].first-v[N-2].first>S) a.push_back(v[N-1].second);
		}
		else{
			if(v[i].first-v[i-1].first>S && v[i+1].first-v[i].first>S) a.push_back(v[i].second);

		}

	}


	int m=a.size();
	cout << m << endl;

	sort(a.begin(),a.end());

	REP(i,m) cout << a[i] << ' ';
	cout << endl;




	return 0;

}
0