khaicodedaunam,tutaorabug
NguyenAnhQuan
c_cpp
2 years ago
764 B
9
Indexable
#include <bits/stdc++.h>
#define LIM 1000000
using namespace std;
int n, k;
int a[LIM];
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> k;
for (int i = 1; i <= n; i++) cin >> a[i];
sort(a + 1, a + 1 + n);
// filter 1
vector <int> f1;
for (int i = 1; i <= n; i++)
if (a[i] % 2 == 0) f1.push_back(a[i]);
// filter 2
vector <int> f2;
f2.push_back(f1[0]);
for (int i = 1; i < f1.size(); i++)
if (f1[i] != f1[i - 1]) f2.push_back(f1[i]);
if (f2.size() == 0)
{
cout << "NO VALUE";
}
else
{
cout << f2[k - 1];
}
return 0;
}
Editor is loading...
Leave a Comment