結果
問題 |
No.2803 Bocching Star
|
ユーザー |
|
提出日時 | 2024-07-12 21:22:02 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 76 ms / 2,000 ms |
コード長 | 1,291 bytes |
コンパイル時間 | 2,460 ms |
コンパイル使用メモリ | 167,028 KB |
実行使用メモリ | 8,476 KB |
最終ジャッジ日時 | 2024-07-12 21:22:20 |
合計ジャッジ時間 | 5,841 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include<bits/stdc++.h> using namespace std; // OM NAMAH SHIVAY #define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define endl "\n" #define int long long #define F first #define S second #define all(x) (x).begin(), (x).end() const int inf = 1e18; // int dx[4]={-1,0,1,0}; // int dy[4]={0,1,0,-1}; // int dx[8]={0,-1,-1,-1,0,1,1,1}; // int dy[8]={1,1,0,-1,-1,-1,0,1}; const int N = 200200; const int mod = 1e9+7; using ii = pair<int,int>; void solver(){ int n,s; cin>>n>>s; vector<ii>arr(n); for(int i=0;i<n;i++) { cin>>arr[i].first; arr[i].second = i; } sort(begin(arr),end(arr)); vector<int>ans; for(int i=0;i<n;i++) { int flg = 1; if(i-1>=0) { if(abs(arr[i-1].F-arr[i].F)<=s) { flg=0; } } if(i+1<n) { if(abs(arr[i+1].F-arr[i].F)<=s) { flg=0; } } if(flg) { ans.push_back(arr[i].second+1); } } sort(begin(ans),end(ans)); cout<<ans.size()<<endl; for(auto x:ans) cout<<x<<" "; cout<<endl; } signed main() { IOS //int _t;cin>>_t;while(_t--) solver(); return 0; } #undef int