結果

問題 No.2757 Pin Game
ユーザー ANKUR PAL
提出日時 2024-05-30 02:58:59
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 560 bytes
コンパイル時間 4,398 ms
コンパイル使用メモリ 120,704 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-20 21:06:27
合計ジャッジ時間 5,412 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

int max_pins_left(int n, int k, vector<int>& x) {
    int last_selected_pin = x[0];
    int count = 1;

    for (int i = 1; i < n; ++i) {
        if (x[i] - last_selected_pin >= k) {
            count += 1;
            last_selected_pin = x[i];
        }
    }

    return count;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> x(n);

    for (int i = 0; i < n; ++i) {
        cin >> x[i];
    }

    int result = max_pins_left(n, k, x);
    cout << result << endl;

    return 0;
}
0