Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- int n, k;
- cin >> n >> k;
- map<int,int>m; //freq
- while (n--) {
- int x; cin >> x;
- m[x]++;
- }
- ll ans=0;
- for (auto [i,v] :m) {
- ans+=v;
- if (ans==k) {
- cout << i << endl;
- return 0;
- }
- if (ans>k) {
- cout << -1 << endl;
- return 0;
- }
- }
- if (ans==k) cout << 1000000000 << endl;
- else cout << -1 << endl;
- return 0;
- }
- /*
- *
- *
- */
Advertisement
Add Comment
Please, Sign In to add comment