結果

問題 No.2757 Pin Game
ユーザー nonon
提出日時 2024-05-18 06:24:28
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 459 bytes
コンパイル時間 1,967 ms
コンパイル使用メモリ 197,452 KB
最終ジャッジ日時 2025-02-21 15:38:24
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/segtree>
using namespace std;
int N,K,X[3<<17];
int op(int a, int b){return max(a,b);}
int e(){return 0;}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>N>>K;
    for(int i=0;i<N;i++)cin>>X[i];
    atcoder::segtree<int,op,e>seg(N);
    int r=0;
    for(int i=0;i<N;i++)
    {
        while(r<i&&X[r]+K<=X[i])r++;
        seg.set(i,seg.prod(0,r)+1);
    }
    cout<<seg.all_prod()<<endl;
}
0