結果
| 問題 |
No.1170 Never Want to Walk
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-09-11 15:27:33 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 65 ms / 2,000 ms |
| コード長 | 711 bytes |
| コンパイル時間 | 2,066 ms |
| コンパイル使用メモリ | 200,984 KB |
| 最終ジャッジ日時 | 2025-02-24 06:39:40 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 37 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#include<atcoder/dsu>
using namespace atcoder;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll N,A,B;
cin>>N>>A>>B;
vector<ll> X(N);
vector<ll> D(N+1,0);
for(int i=0;i<N;i++)cin>>X[i];
dsu d(N);
for(int i=0;i<N;i++){
int r=upper_bound(X.begin(),X.end(),X[i]+B)-X.begin();
int l=lower_bound(X.begin(),X.end(),X[i]+A)-X.begin();
if(l!=r){
d.merge(i,l);
D[l]++;
D[r-1]--;
}
}
for(int i=0;i<N;i++){
D[i+1]+=D[i];
if(D[i]>0)d.merge(i,i+1);
}
for(int i=0;i<N;i++)cout<<d.size(i)<<"\n";
}