Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
959 B
0
Indexable
Never
#include <iostream>
#include <algorithm> 
#include <math.h>
#include <vector>


int main()
{
    int n = 0;
    int input = 0;
    double cost = 0;
    std::cin >> n;
    std::vector<double> prices;
    std::vector<double> cheap;
    std::vector<double> newPrices;
    
    for (int i = 0; i < n; i++) {
        std::cin >> input;
        if (input > 50) {
            prices.push_back(input);
        }
        else {
            cheap.push_back(input);
        }
    }

    int len = prices.size();
    std::sort(prices.rbegin(), prices.rend());

    for (int i = 0; i < len; i++) {
        if(i % 2 == 0) {
            newPrices.push_back(prices[i / 2]);
            cost += prices[i / 2];
        }
        else {
            newPrices.push_back(prices[len - i / 2 - 1]);
            cost += prices[len - i / 2 - 1] * 0.75;
        }
    }

   std::cout << std::ceil(cost) << ' ' << newPrices[len - len % 2 - 1];
}
Leave a Comment