#include
#include
#include
struct Student {
std::string lastName;
int schoolNumber;
std::vector answers;
};
bool compareStudents(const Student& student1, const Student& student2) {
int solved1 = std::count(student1.answers.begin(), student1.answers.end(), 1);
int solved2 = std::count(student2.answers.begin(), student2.answers.end(), 1);
return solved1 > solved2;
}
int main() {
std::vector students;
// Добавление учеников и их ответов на задачи
students.push_back({ "Иванов", 1, { 1, 0, 1, 0, 1 } });
students.push_back({ "Петров", 2, { 1, 1, 0, 1, 0 } });
students.push_back({ "Сидоров", 1, { 0, 0, 1, 1, 1 } });
students.push_back({ "Смирнов", 3, { 0, 1, 0, 1, 0 } });
students.push_back({ "Кузнецов", 2, { 1, 1, 1, 1, 1 } });
// Сортировка учеников по количеству решенных задач
std::sort(students.begin(), students.end(), compareStudents);
// Вывод списка учеников по школам
int currentSchool = 0;
for (const auto& student : students) {
if (student.schoolNumber != currentSchool) {
currentSchool = student.schoolNumber;
std::cout