結果
問題 | No.2757 Pin Game |
ユーザー |
|
提出日時 | 2024-05-17 21:23:58 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 138 ms / 2,000 ms |
コード長 | 514 bytes |
コンパイル時間 | 1,995 ms |
コンパイル使用メモリ | 87,232 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-20 13:09:42 |
合計ジャッジ時間 | 2,333 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 10 |
ソースコード
#include <iostream> #include <vector> using namespace std; using ll = long long; int main () { int N, K; cin >> N >> K; vector<int> X(N); for (int i = 0; i < N; i++) cin >> X[i]; // 貪欲でOK int ans = 0; int i = 0, j = 0; while (i < N) { if (j < i) j = i; ans++; while (j < N) { if (X[j] - X[i] < K) { j++; continue; } break; } i = j; } cout << ans << "\n"; }