結果

問題 No.2803 Bocching Star
ユーザー kentikenti
提出日時 2024-07-12 21:38:49
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 876 bytes
コンパイル時間 1,974 ms
コンパイル使用メモリ 112,560 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-12 21:38:56
合計ジャッジ時間 5,927 ms
ジャッジサーバーID
(参考情報)
judge5 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;

const int MAX_N = 200000, INF = (int)1e9 + 1;
int n, s;
P p[MAX_N];

int main() {
    cin >> n >> s;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        p[i] = make_pair(tmp, i + 1);
    }
    sort(p, p + n);
    priority_queue<int, vector<int>, greater<int>> que;
    int tmp = -INF;
    for (int i = 0; i + 1 < n; i++) {
        if (p[i].first - tmp > s && p[i + 1].first - p[i].first > s)
            que.push(p[i].second);
        tmp = p[i].first; 
    }
    if (n >= 2 && p[n - 1].first - p[n - 2].first > s)
        que.push(n);
    if (n == 1)
        que.push(1);
    cout << que.size() << endl;
    while (!que.empty()) {
        cout << que.top() << " ";
        que.pop();
    }
    cout << endl;
    return 0;
}
0