-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3x2.cpp
More file actions
38 lines (28 loc) · 740 Bytes
/
3x2.cpp
File metadata and controls
38 lines (28 loc) · 740 Bytes
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
// NOTE: it is recommended to use this even if you don't understand the following code.
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
long long N;
vector<long long> P;
int main() {
// uncomment the following lines if you want to read/write from files
//ifstream cin("input.txt");
//ofstream cout("output.txt");
cin >> N;
P.resize(N);
for(long long i = 0; i < N; i++)
cin >> P[i];
// insert your code here
long long ans=0;
sort(P.begin(), P.end());
reverse(P.begin(), P.end());
for (long long i=0; i<N; i++) {
if ((i+1)%3 != 0) {
ans += P[i];
}
}
cout << ans << endl; // print the result
return 0;
}