結果
問題 | No.2803 Bocching Star |
ユーザー |
![]() |
提出日時 | 2024-09-28 15:24:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 64 ms / 2,000 ms |
コード長 | 1,562 bytes |
コンパイル時間 | 1,959 ms |
コンパイル使用メモリ | 200,356 KB |
最終ジャッジ日時 | 2025-02-24 13:57:05 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include<bits/stdc++.h>using namespace std;typedef long long ll;typedef pair<int,int> pii;typedef vector<int> vi;#define RIDLs_code ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);#define fi1(x) for(int i=1;i<=x;++i)#define fi0(x) for(int i=0;i<x;++i)#define fj0(x) for(int j=0;j<x;++j)#define fj1(x) for(int j=1;j<=x;++j)#define For(elem, begin, end) for(int elem=begin;elem<end;++elem)#define RFor(elem, begin, end) for(int elem=begin;elem>=end;--elem)#define all(x) (x).begin(), (x).end()#define pb push_backconst int MOD = 1e9+7;const int INF = 0x3f3f3f3f;bool is[200005]={false};bool cmp(pair<ll, ll> a, pair<ll, ll> b){return a.first<b.first;}void solve(){int n, s, cnt=0;cin>>n>>s;vector<pair<ll, ll>> a;ll pos, ind;fi1(n){cin>>pos;a.push_back(make_pair(pos, i));}if(n==1){cout<<1<<endl;cout<<1<<endl;return;}sort(all(a), cmp);fi0(n){if(i==0){if(a[i+1].first-a[i].first>s){is[a[i].second]=true;cnt++;}}else if(i==n-1){if(a[i].first-a[i-1].first>s){is[a[i].second]=true;cnt++;}}else{if(a[i].first-a[i-1].first>s && a[i+1].first-a[i].first>s){is[a[i].second]=true;cnt++;}}}cout<<cnt<<endl;fi0(n+1){if(is[i]) cout<<i<<" ";}return;}int main(){RIDLs_codeint T=1;// cin>>T;while (T--) solve();return 0;}