We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
using namespace std;
int test(int n, long long k, vector a) {
int dem = 0;
unordered_sets(a.begin(), a.end());
for(int i = 0; i < n; i++) {
if(a[i] > k){
long long tam = a[i] - k;
if(s.find(tam) != s.end()) {
dem++;
}
}
}
return dem;
}
int main() {
int n;
long long k;
cin >> n >> k;
vector a(n);
for(int i = 0; i < n; i++) {
cin >> a[i];
}
cout << test(n, k, a);
return 0;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Pairs
You are viewing a single comment's thread. Return to all comments →
include
using namespace std; int test(int n, long long k, vector a) { int dem = 0; unordered_sets(a.begin(), a.end()); for(int i = 0; i < n; i++) { if(a[i] > k){ long long tam = a[i] - k; if(s.find(tam) != s.end()) { dem++; } } } return dem; } int main() { int n; long long k; cin >> n >> k; vector a(n); for(int i = 0; i < n; i++) { cin >> a[i]; } cout << test(n, k, a); return 0; }