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.
if(t % 5 == 0) return t / 5;
if(t % 5 == 1 || t % 5 == 2) return t / 5 + 1;
return t / 5 + 2;
}
int equal(vector arr) {
int result = 999999999;
sort(arr.begin(), arr.end());
vector<vector<int>> set;
int a = arr[0], b = 0;
for(int i = 0; i < arr.size(); ++i) {
if(arr[i] == a) ++b;
else {
set.push_back({a, b});
a = arr[i];
b = 1;
}
}
set.push_back({a, b});
for(int i = 0; i < 5; ++i) {
int x = 0;
int min = set[0][0] - i;
for(int j = 0; j < set.size(); ++j) {
x += set[j][1] * timeDecrease(set[j][0] - min);
}
if(x < result) result = x;
}
return result;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Minimal Distance to Pi
You are viewing a single comment's thread. Return to all comments →
I think this is exactly what he say:
int timeDecrease(int t) {
}
int equal(vector arr) {
}