結果
| 問題 |
No.2803 Bocching Star
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-12 21:09:35 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 153 ms / 2,000 ms |
| コード長 | 1,113 bytes |
| コンパイル時間 | 946 ms |
| コンパイル使用メモリ | 83,396 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-12 21:10:08 |
| 合計ジャッジ時間 | 5,339 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
using namespace std;
int main() {
int N, S;
cin >> N >> S;
vector<int> P(N);
for (int i = 0; i < N; ++i) {
cin >> P[i];
}
// Pair of (value, original index)
vector<pair<int, int>> Parg(N);
for (int i = 0; i < N; ++i) {
Parg[i] = {P[i], i};
}
// Sort based on the values
sort(Parg.begin(), Parg.end());
vector<int> out;
if (N == 1) {
cout << 1 << endl;
cout << 1 << endl;
return 0;
}
if (Parg[1].first - Parg[0].first > S) {
out.push_back(Parg[0].second);
}
if (Parg[N-1].first - Parg[N-2].first > S) {
out.push_back(Parg[N-1].second);
}
for (int i = 1; i < N - 1; ++i) {
if (Parg[i].first - Parg[i-1].first > S && Parg[i+1].first - Parg[i].first > S) {
out.push_back(Parg[i].second);
}
}
cout << out.size() << endl;
sort(out.begin(), out.end());
for (const int& index : out) {
cout << index + 1 << " ";
}
cout << endl;
return 0;
}