結果
問題 | No.2803 Bocching Star |
ユーザー |
![]() |
提出日時 | 2024-07-12 21:08:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 246 ms / 2,000 ms |
コード長 | 1,177 bytes |
コンパイル時間 | 2,543 ms |
コンパイル使用メモリ | 211,904 KB |
最終ジャッジ日時 | 2025-02-22 03:18:48 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include<bits/stdc++.h>using namespace std;#define REP(i,n)for(int i=0;i<(n);++i)#define REP1(i,n)for(int i=1;i<=(n);++i)#define FORE(...)for(auto&&__VA_ARGS__)#define ALL(x)begin(x),end(x)#define mset(x,y)memset(x,y,sizeof x)#define pb push_back#define eb emplace_back#define V vector#define lb(x,y)(lower_bound(begin(x),end(x),y)-begin(x))#define ub(x,y)(upper_bound(begin(x),end(x),y)-begin(x))template<class T,class S>inline bool chmin(T&A,S B){return A>B?A=B,1:0;}template<class T,class S>inline bool chmax(T&A,S B){return A<B?A=B,1:0;}void fastIO(){ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}using Int=long long;using Real=long double;using PII=pair<int,int>;using PLL=pair<Int,Int>;int main(){int N,S;cin>>N>>S;V<PII>P(N);REP(i,N){cin>>P[i].first;P[i].second=i;}sort(ALL(P));map<int,int>mp;V<int>PP(N);REP(i,N)PP[i]=P[i].first,++mp[PP[i]];V<int>ans;REP(i,N){int idL=lb(PP,PP[i]-S);int idR=lb(PP,PP[i]+1);if(PP[idL]==PP[i]&&(idR==N||PP[i]+S<PP[idR])&&mp[PP[i]]==1){ans.pb(P[i].second+1);}}sort(ALL(ans));cout<<size(ans)<<endl;REP(i,size(ans))cout<<ans[i]<<" \n"[i==size(ans)-1];}