-
Notifications
You must be signed in to change notification settings - Fork 0
/
akcija.cpp
51 lines (42 loc) · 954 Bytes
/
akcija.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* @file akcija.cpp
* @author William Weston
* @brief Akcija Problem from Kattis
* @version 0.1
* @date 2023-06-30
*
* @copyright Copyright (c) 2023
*
* Source: https://open.kattis.com/problems/akcija
*/
#include <algorithm> // sort
#include <cstdlib>
#include <functional> // greater
#include <iostream>
#include <vector>
auto
main() -> int
{
int N;
while ( std::cin >> N )
{
auto book_prices = std::vector<int>();
for ( auto idx = 0; idx < N; ++idx )
{
int tmp;
std::cin >> tmp;
book_prices.push_back( tmp );
}
std::sort( book_prices.begin(), book_prices.end(), std::greater{} );
auto total_price = 0;
for ( auto idx = 0; idx < N; ++idx )
{
if ( ( idx + 1 ) % 3 != 0 )
{
total_price += book_prices[idx];
}
}
std::cout << total_price << '\n';
}
return EXIT_SUCCESS;
}