Загрузка данных


#include <iostream>
#include <vector>

int main() {
    int n;
    std::cin >> n;

    std::vector<int> participants(n);
    int positive_count = 0;
    std::vector<int> last_negatives;

    for (int i = 0; i < n; ++i) {
        std::cin >> participants[i];
        if (participants[i] > 0) {
            positive_count++;
        }
    }

    for (int i = n - 1; i >= 0 && last_negatives.size() < 3; --i) {
        if (participants[i] < 0) {
            last_negatives.push_back(participants[i]);
        }
    }

    std::cout << positive_count << std::endl;

    for (int i = 0; i < last_negatives.size(); ++i) {
        std::cout << last_negatives[i] << " ";
    }
    if (!last_negatives.empty()) {
        std::cout << std::endl;
    }

    return 0;
}