日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

The Preliminary Contest for ICPC Asia Xuzhou 2019 徐州网络赛 XKC's basketball team

發(fā)布時(shí)間:2023/12/15 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 The Preliminary Contest for ICPC Asia Xuzhou 2019 徐州网络赛 XKC's basketball team 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

XKC , the captain of the basketball team , is directing a train of?nn?team members. He makes all members stand in a row , and numbers them?1 \cdots n1?n?from left to right.

The ability of the?ii-th person is?w_iwi??, and if there is a guy whose ability is not less than?w_i+mwi?+m?stands on his right , he will become angry. It means that the?jj-th person will make the?ii-th person angry if?j>ij>i?and?w_j \ge w_i+mwj?≥wi?+m.

We define the anger of the?ii-th person as the number of people between him and the person , who makes him angry and the distance from him is the longest in those people. If there is no one who makes him angry , his anger is?-1?1?.

Please calculate the anger of every team member .

Input

The first line contains two integers?nn?and?m(2\leq n\leq 5*10^5, 0\leq m \leq 10^9)m(2≤n≤5?105,0≤m≤109)?.

The following? line contain?nn?integers?w_1..w_n(0\leq w_i \leq 10^9)w1?..wn?(0≤wi?≤109)?.

Output

A row of?nn?integers separated by spaces , representing the anger of every member .

樣例輸入復(fù)制

6 1 3 4 5 6 2 10

樣例輸出復(fù)制

4 3 2 1 0 -1


隊(duì)友做的,沒大有思路。

#include<cstdio> #include<vector> #include<queue> #include<cmath> #include<iostream> #include<cstring> #include<algorithm> using namespace std; #define LL long long #define MAXN 500100 struct node {LL x;LL y; } a[MAXN*2]; LL b[MAXN],c[MAXN]; bool cmp(node u,node v) {return u.x<v.x; } int main() {LL n,m,i,j;scanf("%lld%lld",&n,&m);for(i=1; i<=n; i++){scanf("%lld",&a[i].x);a[i].y=i;b[i]=a[i].x;}j=n;sort(a+1,a+n+1,cmp);bool flag=false;for(i=1; i<=n; i++){while(b[j]<a[i].x+m){if(j==0){flag=true;break;}j--;}if(flag)c[a[i].y]=-1;else{if(j<=a[i].y) c[a[i].y]=-1;elsec[a[i].y]=j-a[i].y-1;}}for(i=1; i<n; i++)printf("%lld ",c[i]);printf("%lld",c[n]);return 0; }

總結(jié)

以上是生活随笔為你收集整理的The Preliminary Contest for ICPC Asia Xuzhou 2019 徐州网络赛 XKC's basketball team的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。