結果
問題 |
No.2803 Bocching Star
|
ユーザー |
![]() |
提出日時 | 2024-07-12 21:05:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 142 ms / 2,000 ms |
コード長 | 930 bytes |
コンパイル時間 | 2,636 ms |
コンパイル使用メモリ | 204,708 KB |
最終ジャッジ日時 | 2025-02-22 03:16:21 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; const int INF = 1e9 + 10; const ll INFL = 4e18; int main() { int N, S; cin >> N >> S; vector<int> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } vector<pair<int, int>> P(N); for (int i = 0; i < N; i++) { P[i] = {A[i], i}; } sort(P.begin(), P.end()); vector<int> ans; for (int i = 0; i < N; i++) { bool ok = true; if (i > 0) { if (P[i - 1].first >= P[i].first - S) { ok = false; } } if (i < N - 1) { if (P[i + 1].first <= P[i].first + S) { ok = false; } } if (ok) { ans.push_back(P[i].second); } } sort(ans.begin(), ans.end()); cout << ans.size() << endl; for (int x : ans) { cout << ++x << ' '; } cout << endl; }