結果
問題 |
No.2803 Bocching Star
|
ユーザー |
|
提出日時 | 2024-07-05 10:27:05 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 125 ms / 2,000 ms |
コード長 | 840 bytes |
コンパイル時間 | 1,760 ms |
コンパイル使用メモリ | 200,180 KB |
最終ジャッジ日時 | 2025-02-22 02:11:39 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main(){ int n, s; cin >> n >> s; assert(1 <= n && n <= 200000); assert(0 <= s && s <= 1000000000); vector<int> p(n); for(int i = 0; i < n; i++){ cin >> p[i]; assert(0 <= p[i] && p[i] <= 1000000000); } vector<int> ind(n); for(int i = 0; i < n; i++) ind[i] = i; sort(ind.begin(), ind.end(), [&](int i, int j){ return p[i] < p[j]; }); vector<int> ans(n, 1); for(int i = 0; i < n; i++){ if(i != 0 && p[ind[i]] - p[ind[i-1]] <= s){ ans[ind[i]] = 0; ans[ind[i-1]] = 0; } } vector<int> fans; for(int i = 0; i < n; i++) if(ans[i] == 1) fans.push_back(i+1); cout << (int)fans.size() << '\n'; for(int i = 0; i < (int)fans.size(); i++){ if(i == (int)fans.size()-1) cout << fans[i] << '\n'; else cout << fans[i] << " "; } if((int)fans.size() == 0) cout << '\n'; }