Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int t,n,k,p,c,w;
- vector <int> v;
- int main() {
- cin >> t;
- while(t--) {
- cin >> n >> k >> p;
- c = 0;
- v.clear();
- for (int i = 0; i < k; i++) {
- cin >> w;
- v.push_back(w);
- }
- sort(v.begin(),v.end());
- for (int i = 0; i < k; i++) {
- if (v[i]>p) break;
- c++;
- }
- if (p+c > n) cout << -1 << endl; else cout << p+c << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement