結果
問題 | No.2803 Bocching Star |
ユーザー | shu |
提出日時 | 2024-07-12 21:06:43 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 76 ms / 2,000 ms |
コード長 | 763 bytes |
コンパイル時間 | 5,827 ms |
コンパイル使用メモリ | 299,348 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-12 21:07:41 |
合計ジャッジ時間 | 9,132 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#pragma GCC optimize("O3") #ifdef LOCAL #include "algo/debug_ver3.hpp" #else #define debug(...) #define debugArr(...) #endif #include <bits/stdc++.h> using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n, s; cin >> n >> s; vector<pair<int, int>> p(n); for (int i = 0; i < n; ++i) { cin >> p[i].first; p[i].second = i; } sort(p.begin(), p.end()); vector<int> ans; for (int i = 0; i < n; ++i) { if ((i - 1 < 0 || p[i].first - p[i - 1].first > s) && (i + 1 >= n || p[i + 1].first - p[i].first > s)) { ans.push_back(p[i].second); } } sort(ans.begin(), ans.end()); cout << ans.size() << '\n'; for (int i = 0; i < (int)ans.size(); ++i) { cout << (i == 0 ? "" : " ") << ans[i] + 1; } cout << '\n'; }