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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

Dreamoon and Ranking Collection CodeForces - 1330A (贪心)

發布時間:2023/12/4 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Dreamoon and Ranking Collection CodeForces - 1330A (贪心) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題意:

大意就是給一個序列,可能有重復數字,有x次機會為這個序列填上一個數字,問最終從里面獲得的1~v連續子序列的v最大是多少。

題目:

Dreamoon is a big fan of the Codeforces contests.

One day, he claimed that he will collect all the places from 1 to 54 after two more rated contests. It’s amazing!

Based on this, you come up with the following problem:

There is a person who participated in n Codeforces rounds. His place in the first round is a1, his place in the second round is a2, …, his place in the n-th round is an.

You are given a positive non-zero integer x.

Please, find the largest v such that this person can collect all the places from 1 to v after x more rated contests.

In other words, you need to find the largest v, such that it is possible, that after x more rated contests, for each 1≤i≤v, there will exist a contest where this person took the i-th place.

For example, if n=6, x=2 and a=[3,1,1,5,7,10] then answer is v=5, because if on the next two contest he will take places 2 and 4, then he will collect all places from 1 to 5, so it is possible to get v=5.

Input

The first line contains an integer t (1≤t≤5) denoting the number of test cases in the input.

Each test case contains two lines. The first line contains two integers n,x (1≤n,x≤100). The second line contains n positive non-zero integers a1,a2,…,an (1≤ai≤100).

Output

For each test case print one line containing the largest v, such that it is possible that after x other contests, for each 1≤i≤v, there will exist a contest where this person took the i-th place.

Example

Input

5
6 2
3 1 1 5 7 10
1 100
100
11 1
1 1 1 1 1 1 1 1 1 1 1
1 1
1
4 57
80 60 40 20

Output

5
101
2
2
60

分析:

其實讀懂這道題的題意,基本都能寫出來,A題一般都簡單,這里說下我對這道題的分析:
1.我首先想到map,記錄出現的值。
2.用一個while循環,直到找到第m次的“空位”
3.結果用了減二,因為while循環,先判斷再運行再判斷這樣就會多加2
4.起始即為1,題目要求從1開始。

AC代碼:

#include<stdio.h> #include<string.h> #include<map> #include<algorithm> using namespace std; const int M=1e3+10; int t,n,m,ans,k; int a[M]; int main() {scanf("%d",&t);while(t--){map<int,int>mp;scanf("%d%d",&n,&m);for(int i=0;i<n;i++){scanf("%d",&a[i]);mp[a[i]]++;}k=0;ans=1;while(k<=m){if(!mp[ans])k++;ans++;}printf("%d\n",ans-2);} }
In addtion

最近想提高下自己博客的閱讀量,就會開始盡量把以后所有寫過的CodeForces,發到博客上,因為題會新一點,也希望能幫到你們,我會開一個新分類。就醬!

總結

以上是生活随笔為你收集整理的Dreamoon and Ranking Collection CodeForces - 1330A (贪心)的全部內容,希望文章能夠幫你解決所遇到的問題。

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

主站蜘蛛池模板: 小毛片网站 | 伊人中文字幕在线 | 香蕉在线看 | 女人的洗澡毛片毛多 | 3d动漫精品啪啪一区二区免费 | 亚洲一区二区三区欧美 | 91入囗| 亚洲色图网友自拍 | 欧美精品99| 在线视频观看 | 天天操,夜夜操 | 97人妻人人揉人人躁人人 | 日韩欧美一区二区三区在线 | 少妇影院在线观看 | 福利国产视频 | 奇米久久久 | 亚洲区一区 | 成人黄色片在线观看 | 国产美女视频网站 | 国产女在线 | 国产经典一区二区三区 | 国产精品97 | 免费成人进口网站 | 在线资源av| 国产精品免费无遮挡无码永久视频 | 国产一级在线观看 | aa丁香综合激情 | 亚洲欧美日韩国产一区二区三区 | 青草视频免费在线观看 | www日本色 | 久久永久免费 | 奇米影视亚洲 | 人妻互换一区二区激情偷拍 | 男人的天堂一区 | 国产私拍视频 | 99这里有精品 | 天天综合天天 | 一区二区三区偷拍 | 无遮挡国产 | 国产精品久久久久久久久久免费 | 久久b| 五月婷婷综合在线观看 | 日韩国产精品一区二区三区 | 中文字幕一区二区三区人妻在线视频 | 国产成人宗合 | 免费成人在线电影 | 国产av 一区二区三区 | 依依激情网 | 国产日比视频 | 激情五月色婷婷 | 欧美一级视频免费观看 | 欧美h在线观看 | 天天av综合| 7x7x7x人成影视 | 久久久久久欧美精品se一二三四 | 国产主播福利在线 | 欧美日韩一区二区三区四区 | caoporn视频在线观看 | 日韩不卡视频在线 | 五月婷婷色综合 | 日本国产亚洲 | 天天爽夜夜爽 | 成人午夜视频在线免费观看 | 国产鲁鲁 | 97超碰在线免费 | 草草影院一区二区三区 | 国产成人在线视频观看 | 玖玖爱精品 | 国产精品2| 精品少妇久久 | 四川操bbb| 一个色av | 波多野结衣乳巨码无在线观看 | 亚洲啪啪免费视频 | 精品久久久久一区二区国产 | 激情六月丁香 | 波多野42部无码喷潮 | 尤物视频在线观看国产 | 国产精品久久久不卡 | 成人黄色激情视频 | 欧美日韩影院 | 日韩一二三四 | 亚洲永久精品国产 | 国产情侣久久 | ass精品国模裸体欣赏pics | 欧美在线天堂 | 中文字幕一区二区三区手机版 | 国产视频黄色 | 欧美变态网站 | 国产午夜视频在线观看 | 亚洲一区二区三区四区 | 国产91在线视频观看 | 波多野结衣一区二区 | 久久成人一区 | 国产福利在线视频观看 | 99久久婷婷国产综合精品电影 | 理论片高清免费理伦片 | 中文字幕av播放 | 国产成人综合精品 |