-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1873E.cpp
More file actions
33 lines (33 loc) · 702 Bytes
/
1873E.cpp
File metadata and controls
33 lines (33 loc) · 702 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include<bits/stdc++.h>
using namespace std;
int main(){
long long a, n, w, g;
cin >> a;
for(int b=0; b<a; b++){
cin >> n >> w;
vector<int> v(n,0);
cin >> g;
v[0] = g;
long long min = g;
for(int i=1; i<n;i++){
cin >> g;
if(g < min){min = g;}
v[i] = g;
}
long long h = min+1;
while(w!=0){
long long c = 0;
for(int j=0; j<n; j++){
if(v[j] < h){c++;}
}
if(c<=w){
w-=c;
h++;
}
else{
w = 0;
}
}
cout << h-1 << endl;
}
}