結果
| 問題 |
No.2803 Bocching Star
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-12 21:14:22 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 122 ms / 2,000 ms |
| コード長 | 1,021 bytes |
| コンパイル時間 | 1,889 ms |
| コンパイル使用メモリ | 108,992 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-12 21:14:37 |
| 合計ジャッジ時間 | 6,376 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
constexpr int iINF = 1'000'000'000;
constexpr ll llINF = 1'000'000'000'000'000'000;
int main () {
int N, S; cin >> N >> S;
vector<int> P(N);
for (int i = 0; i < N; i++) cin >> P[i];
vector<int> index(N);
for (int i = 0; i < N; i++) index[i] = i;
sort(index.begin(), index.end(), [&](int a, int b) { return P[a] < P[b]; });
vector<bool> isolated(N);
int count = 0;
for (int i = 0; i < N; i++) {
bool res = true;
if (0 < i) {
if (P[index[i]] - P[index[i - 1]] <= S) res = false;
}
if (i + 1 < N) {
if (P[index[i + 1]] - P[index[i]] <= S) res = false;
}
isolated[index[i]] = res;
if (res) count++;
}
cout << count << "\n";
int lat = 0;
for (int i = 0; i < N; i++) {
if (!isolated[i]) continue;
cout << i + 1 << (lat == count - 1 ? '\n' : ' ');
lat++;
}
}