結果

問題 No.2803 Bocching Star
コンテスト
ユーザー 2475057t
提出日時 2024-07-13 11:12:07
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 943 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 238 ms
コンパイル使用メモリ 38,852 KB
最終ジャッジ日時 2026-02-22 11:50:15
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>
#include <stdlib.h>

// 比較関数(qsort用)
int cmp(const void *a, const void *b) {
    return (*(int *)a - *(int *)b);
}

int main(void){

    int N, S;
    scanf("%d %d", &N, &S);
    int p[N];
    for(int i = 0; i < N; i++){
        scanf("%d", &p[i]);
    }

    // 配列pをソート
    qsort(p, N, sizeof(int), cmp);

    int r[N], cnt = 0;
    for(int i = 0; i < N; i++){
        int isolated = 1; // 初期状態は孤立していると仮定
        if (i > 0 && abs(p[i] - p[i - 1]) <= S) {
            isolated = 0; // 左側に距離S以内の要素がある場合
        }
        if (i < N - 1 && abs(p[i] - p[i + 1]) <= S) {
            isolated = 0; // 右側に距離S以内の要素がある場合
        }
        if (isolated) {
            r[cnt] = i;
            cnt++;
        }
    }

    for(int k = 0; k < cnt; k++){
        printf("%d ", r[k]);
    }
    printf("\n");

    return 0;
}
0