結果

問題 No.2803 Bocching Star
ユーザー forest3forest3
提出日時 2024-07-13 17:11:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 903 bytes
コンパイル時間 1,906 ms
コンパイル使用メモリ 178,304 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-13 17:12:02
合計ジャッジ時間 7,001 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 15 ms
6,940 KB
testcase_04 AC 90 ms
6,940 KB
testcase_05 AC 46 ms
6,940 KB
testcase_06 AC 11 ms
6,944 KB
testcase_07 AC 37 ms
6,940 KB
testcase_08 AC 20 ms
6,944 KB
testcase_09 AC 93 ms
6,944 KB
testcase_10 AC 97 ms
6,940 KB
testcase_11 AC 109 ms
6,940 KB
testcase_12 AC 33 ms
6,944 KB
testcase_13 AC 78 ms
6,940 KB
testcase_14 AC 54 ms
6,940 KB
testcase_15 AC 103 ms
6,940 KB
testcase_16 AC 57 ms
6,940 KB
testcase_17 AC 19 ms
6,940 KB
testcase_18 AC 14 ms
6,944 KB
testcase_19 AC 83 ms
6,940 KB
testcase_20 AC 51 ms
6,944 KB
testcase_21 AC 40 ms
6,940 KB
testcase_22 AC 39 ms
6,940 KB
testcase_23 AC 103 ms
6,940 KB
testcase_24 AC 126 ms
6,940 KB
testcase_25 AC 120 ms
6,944 KB
testcase_26 AC 119 ms
6,940 KB
testcase_27 AC 111 ms
6,940 KB
testcase_28 AC 113 ms
6,944 KB
testcase_29 AC 104 ms
6,940 KB
testcase_30 AC 122 ms
6,944 KB
testcase_31 AC 103 ms
6,944 KB
testcase_32 AC 123 ms
6,944 KB
testcase_33 AC 3 ms
6,940 KB
testcase_34 AC 3 ms
6,944 KB
testcase_35 AC 2 ms
6,944 KB
testcase_36 AC 3 ms
6,940 KB
testcase_37 AC 3 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)

int main() {
	int N, s;
	cin >> N >> s;
	using P = pair<int, int>;
	vector<P> p(N);
	rep(i, N) {
		int a;
		cin >> a;
		p[i] = P(a, i);
	}
	sort(p.begin(), p.end());
	vector<int> ans;
	if(N == 1) ans.push_back(p[0].second);
	else {
		rep(i, N) {
			if(i == 0) {
				if(i + 1 < N && abs(p[i].first - p[i + 1].first) > s) ans.push_back(p[i].second);
			}
			else if(i == N - 1) {
				if(i - 1 >= 0 && abs(p[i].first - p[i - 1].first) > s) ans.push_back(p[i].second);
			}
			else {
				if(i + 1 < N && i - 1 >= 0 && abs(p[i].first - p[i + 1].first) > s && abs(p[i].first - p[i - 1].first) > s)
					ans.push_back(p[i].second);
			}
		}
	}
	int sz = ans.size();
	sort(ans.begin(), ans.end());
	cout << sz << endl;
	rep(i, sz) {
		if(i) cout << " ";
		cout << ans[i] + 1;
	}
	cout << endl;
}
0