結果
問題 | No.2803 Bocching Star |
ユーザー |
|
提出日時 | 2024-07-12 21:44:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 157 ms / 2,000 ms |
コード長 | 687 bytes |
コンパイル時間 | 2,529 ms |
コンパイル使用メモリ | 203,792 KB |
最終ジャッジ日時 | 2025-02-22 03:45:49 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;ll const inf = (ll)1e18;int main () {int N, S;cin >> N >> S;std::vector<ll> P(N + 2) ;P[0] = -inf; P[N + 1] = inf;for (int i = 1; i <= N; i ++) cin >> P[i];vector<int> ID(N + 2);iota(ID.begin(), ID.end(), 0);sort(ID.begin(), ID.end(), [&](int a, int b) {return P[a] < P[b];});vector<int> ans;for (int p = 1; p <= N; p ++) {int i = ID[p];int l = ID[p - 1], r = ID[p + 1];if (min(abs(P[l] - P[i]), abs(P[r] - P[i])) > S) {ans.push_back(i);}}sort(ans.begin(), ans.end());cout << ans.size() << endl;for (auto& a : ans) cout << a << (a == ans.back() ? "" : " ");cout << endl;}