結果
問題 | No.2803 Bocching Star |
ユーザー |
|
提出日時 | 2024-07-12 21:11:29 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 122 ms / 2,000 ms |
コード長 | 619 bytes |
コンパイル時間 | 3,371 ms |
コンパイル使用メモリ | 263,128 KB |
実行使用メモリ | 8,604 KB |
最終ジャッジ日時 | 2024-07-12 21:11:37 |
合計ジャッジ時間 | 7,370 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;int main() {ios::sync_with_stdio(false);cin.tie(nullptr);ll N, K;cin >> N >> K;vector<ll> A(N);for(auto &i : A) { cin >> i; }vector<ll> idx(N);iota(idx.begin(), idx.end(), 0);ranges::sort(idx, [&](auto i, auto j) { return A[i] < A[j]; });ranges::sort(A);vector<ll> ans;for(ll i = 0; i < N; i++) {if(ranges::upper_bound(A, A[i] + K) - ranges::lower_bound(A, A[i] - K) == 1) { ans.emplace_back(idx[i]); }}ranges::sort(ans);cout << ans.size() << "\n";for(auto &i : ans) { cout << ++i << " "; }}