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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Social Distance

發布時間:2024/5/14 编程问答 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Social Distance 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Codeforces Round #783 (Div. 2)? ? ?B題

mm?chairs are arranged in a circle sequentially. The chairs are numbered from?00?to?m?1m?1.?nn?people want to sit in these chairs. The?ii-th of them wants at least?a[i]a[i]?empty chairs both on his right and left side.

More formally, if the?ii-th person sits in the?jj-th chair, then no one else should sit in the following chairs:?(j?a[i])modm(j?a[i])modm,?(j?a[i]+1)modm(j?a[i]+1)modm, ...?(j+a[i]?1)modm(j+a[i]?1)modm,?(j+a[i])modm(j+a[i])modm.

Decide if it is possible to sit down for all of them, under the given limitations.

Input

The input consists of multiple test cases. The first line contains a single integer?tt?(1≤t≤5?1041≤t≤5?104) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers?nn?and?mm?(2≤n≤1052≤n≤105,?1≤m≤1091≤m≤109) — the number of people and the number of chairs.

The next line contains?nn?integers,?a1a1,?a2a2, ...?anan?(1≤ai≤1091≤ai≤109) — the minimum number of empty chairs, on both sides of the?ii-th person.

It is guaranteed that the sum of?nn?over all test cases will not exceed?105105.

Output

For each test case print "YES" (without quotes) if it is possible for everyone to sit down and fulfil the restrictions, and "NO" (without quotes) otherwise.

You may print every letter in any case you want (so, for example, the strings "yEs", "yes", "Yes" and "YES" will all be recognized as positive answers).

Example

input

Copy

6 3 2 1 1 1 2 4 1 1 2 5 2 1 3 8 1 2 1 4 12 1 2 1 3 4 19 1 2 1 3

output

Copy

NO YES NO YES NO YES

Note

Test case?11:?n>mn>m, so they can not sit down.

Test case?22: the first person can sit?22-nd and the second person can sit in the?00-th chair. Both of them want at least?11?empty chair on both sides, chairs?11?and?33?are free, so this is a good solution.

Test case?33: if the second person sits down somewhere, he needs?22?empty chairs, both on his right and on his left side, so it is impossible to find a place for the first person, because there are only?55?chairs.

Test case?44: they can sit in the?11-st,?44-th,?77-th chairs respectively.

思路:這個題理解錯題了,這個題問能問否在滿足條件的情況下讓他們都坐下,是我理解錯題了,直接去模擬了,導致錯了無數次。讓他們都能坐下要讓最大的去覆蓋較大的,不能去覆蓋最小的,因為區間的數量是一定的,最大的一定會覆蓋兩次,如果讓最大的去覆蓋小的就會使剩下的區間由較大的去覆蓋,如果讓小的去覆蓋小的,就會讓他們的值都是小的,大的覆蓋小的他們的值會多出來較大的。所以直接排序來讓小的覆蓋小的。

完整代碼:

#include <bits/stdc++.h>using namespace std;#define int long long const int mod=1e9+7;const int N=1e5+10; int a[N];void solve() {int n,m;cin>>n>>m;for(int i=1;i<=n;i++){cin>>a[i];}sort(a+1,a+1+n);int ans=0;ans+=(n+a[n]);for(int i=n;i>=2;i--){ans+=a[i];}if(ans<=m)cout<<"YES"<<endl;else cout<<"NO"<<endl; }signed main() {ios_base::sync_with_stdio(false);cin.tie(NULL);int t;cin>>t;while(t--){solve();}return 0; }

總結

以上是生活随笔為你收集整理的Social Distance的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 欧美成人h版| 嫩草影院在线免费观看 | v片在线看 | 91系列在线观看 | 全国最大色 | 日本在线视频www色 国产在线视频网址 | 亚洲区av | 华丽的外出在线观看 | 无码人妻aⅴ一区二区三区日本 | 日韩欧美中字 | 农村偷人一级超爽毛片 | 欧美色哟哟 | 国产在线麻豆 | 成人黄色在线视频 | 国产一二区在线 | 亚洲一区二区图片 | 亚洲天堂资源网 | 免费成人视屏 | 亚洲第一av网 | 乌克兰性极品xxxhd | 欧美日批| 葵司ssni-879在线播放 | 小嫩女直喷白浆 | 人妻夜夜爽天天爽三区麻豆av网站 | 欧美成人午夜精品久久久 | 婷婷激情久久 | 亚州春色 | 五月天国产在线 | 久久蜜桃av一区二区天堂 | 国产成人高清在线 | 欧美日韩电影一区二区三区 | 美女乱淫 | 免费看黄网站在线观看 | 精品国产乱码久久久人妻 | 深田咏美在线x99av | 一区成人 | 中文亚洲欧美 | jizz免费视频 | 国产精品男同 | 日日操夜夜操视频 | 乖女从小调教h尿便器小说 欧美韩一区二区 | 亚洲加勒比 | 精品小视频| 性欧美18一19性猛交 | 懂色av一区二区三区免费观看 | 国产3区| 亚洲激情在线视频 | 国产在线不卡一区 | 日韩中文字幕亚洲精品欧美 | 宅男噜噜噜66一区二区 | 午夜精品久久99蜜桃的功能介绍 | 国产精品社区 | 一区二区三区四区在线播放 | 69视频一区二区三区 | 国产精品女教师 | 91小视频在线 | 高清国产午夜精品久久久久久 | 久久精品亚洲精品国产欧美 | 久久日av| 伊人久久亚洲综合 | 伊人99| 少妇又色又紧又爽又刺激视频 | 国产99久久久欧美黑人 | 日本激情一区二区 | 九九热精彩视频 | 亚洲区自拍 | 一区二区国产在线观看 | 怡春院欧美 | 九九精品免费视频 | 深夜免费福利视频 | 成人短视频在线 | 成人免费观看视频网站 | 成人www视频| 校园春色av | 成人福利免费视频 | 国产网站视频 | 性网爆门事件集合av | 少妇网站在线观看 | 一本色道久久综合亚洲精品小说 | 国内精品99| 亚洲爱爱av| 久久亚洲综合色 | 福利视频h | 天天狠天天干 | 91网站免费视频 | 天堂网在线最新版www中文网 | 免费成人91 | 精品国偷自产一区二区三区 | 美女娇喘| 巨胸大乳www视频免费观看 | 91精品国产综合久久精品 | 久久久中文 | 女裸全身无奶罩内裤内衣内裤 | 亚洲永久av | 黄色永久免费网站 | 日韩av在线一区二区三区 | 欧洲精品在线观看 | 欧美福利一区二区三区 | 久久日韩 |