You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
751 B

#ifndef DUMMY_LIB_HPP
#define DUMMY_LIB_HPP
#include <vector>
#include <algorithm>
namespace performance_measuring {
int count_on_the_way(const std::vector<int>& v)
{
int min = v[0];
int c = 1;
for (int i = 1; i < v.size(); ++i) {
if (v[i] > min) {
continue;
} if (v[i] == min) {
++c;
} else {
min = v[i];
c = 1;
}
}
return c;
}
int min_element_and_count(const std::vector<int>& v)
{
int min = *std::min_element(v.begin(), v.end());
return std::count(v.begin(), v.end(), min);
}
int sort_and_upper_bound(const std::vector<int>& v)
{
std::vector<int> tmp(v);
std::sort(tmp.begin(), tmp.end());
const auto p = std::upper_bound(tmp.begin(), tmp.end(), *tmp.begin());
return std::distance(tmp.begin(), p);
}
}
#endif