#include<bits/stdc++.h>
using namespace std;
int main()
{
// freopen("a.gir","r",stdin);
// freopen("a.cik","w",stdout);
int n;
int dizi[100007];
cin >> n;
for(int i=0;i<n;i++)
{
cin >> dizi[i];
}
sort(dizi,dizi+n);
long long int fiyat=0;
int i;
for(i=0;i<n%3;i++)
{
fiyat+=dizi[i];
}
for(;i<n-2;i+=3)
{
fiyat+=dizi[i+1]+dizi[i+2];
}
cout << fiyat;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
45 ms |
652 KB |
Output is correct |
7 |
Correct |
40 ms |
644 KB |
Output is correct |
8 |
Correct |
39 ms |
632 KB |
Output is correct |
9 |
Correct |
60 ms |
760 KB |
Output is correct |
10 |
Correct |
58 ms |
632 KB |
Output is correct |