結果

問題 No.2803 Bocching Star
ユーザー vjudge1
提出日時 2024-09-28 15:34:46
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 1,086 bytes
コンパイル時間 976 ms
コンパイル使用メモリ 82,960 KB
最終ジャッジ日時 2025-02-24 13:57:33
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
// pos
#define x first
// inode
#define y second
const int maxN = 2e5 + 5;
typedef pair<ll, ll> star;

ll N, S;
star P[maxN];
bool judge[maxN];

vector<int> ans;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin >> N >> S;
    for (int i = 1; i <= N; i++)
    {
        P[i].y = i;
        cin >> P[i].x;
    }
    sort(P + 1, P + N + 1);
    memset(judge, true, sizeof(judge));


    for (int i = 1; i <= N; i++)
    {
        if (i == 1)    continue;

        star pre = P[i - 1];
        star now = P[i];

        if ( pre.x + S >= now.x)
        {
            judge[i - 1] = false;
            judge[i] = false;
        }
    }

    int cnt = 0;
    for (int i = 1; i <= N; i++)
    {
        if(judge[i])
        {
            cnt++;
            ans.push_back(P[i].y);
        }
    }
    sort(ans.begin(),ans.end());

    cout << cnt << endl;
    for (auto tmp : ans)
        cout << tmp << ' ';

    return 0;
}
0