upd
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <iomanip>
|
||||
|
||||
struct Acc {
|
||||
double sum = 0;
|
||||
size_t count = 0;
|
||||
|
||||
void operator()(double value) {
|
||||
sum += value;
|
||||
count++;
|
||||
}
|
||||
};
|
||||
|
||||
int main() {
|
||||
std::vector<double> data;
|
||||
|
||||
double value;
|
||||
while (std::cin >> value) data.push_back(value);
|
||||
|
||||
size_t n = data.size();
|
||||
size_t first_cut = n / 10;
|
||||
|
||||
auto it_begin = data.begin() + first_cut;
|
||||
auto it_end = data.end() - first_cut;
|
||||
|
||||
std::sort(it_begin, it_end);
|
||||
|
||||
size_t min_cut = (it_end - it_begin) / 10;
|
||||
|
||||
it_begin += min_cut;
|
||||
it_end -= min_cut;
|
||||
|
||||
Acc acc = std::for_each(it_begin, it_end, Acc());
|
||||
|
||||
std::cout << std::fixed << std::setprecision(10);
|
||||
std::cout << acc.sum / acc.count << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
+17
-3
@@ -4,7 +4,7 @@ public:
|
||||
virtual ~Figure() {}
|
||||
};
|
||||
|
||||
class Rectangle : Figure {
|
||||
class Rectangle : public Figure {
|
||||
int a;
|
||||
int b;
|
||||
public:
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class Triangle : Figure {
|
||||
class Triangle : public Figure {
|
||||
int a;
|
||||
int b;
|
||||
int c;
|
||||
@@ -33,4 +33,18 @@ public:
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// #include <cassert>
|
||||
|
||||
// int main() {
|
||||
// Rectangle r1(10, 5), r2(10, 2), r3(10, 5), r4(5, 10);
|
||||
// Triangle t1(1, 2, 3);
|
||||
// Figure* f = &r1;
|
||||
|
||||
// assert(!f->equals(&r2));
|
||||
// assert(f->equals(&r3));
|
||||
// assert(!f->equals(&r4));
|
||||
// assert(!f->equals(&t1));
|
||||
// assert(!f->equals(nullptr));
|
||||
// }
|
||||
@@ -0,0 +1,38 @@
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
std::chrono::system_clock::time_point parse_date(const std::string& date_str) {
|
||||
std::tm tm = {};
|
||||
std::istringstream ss(date_str);
|
||||
ss >> std::get_time(&tm, "%Y-%m-%d");
|
||||
|
||||
return std::chrono::system_clock::from_time_t(std::mktime(&tm));
|
||||
}
|
||||
|
||||
int days_between(const std::chrono::system_clock::time_point& start, const std::chrono::system_clock::time_point& end) {
|
||||
auto duration = end - start;
|
||||
|
||||
return std::chrono::duration_cast<std::chrono::hours>(duration).count() / 24;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int sum = 0;
|
||||
|
||||
std::string date1, date2;
|
||||
std::cin >> date1;
|
||||
|
||||
while (std::cin >> date2) {
|
||||
auto start = parse_date(date1);
|
||||
auto end = parse_date(date2);
|
||||
|
||||
sum += std::abs(days_between(start, end));
|
||||
|
||||
date1 = date2;
|
||||
}
|
||||
|
||||
std::cout << sum << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user