#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const ll maxn=5e5+100;
const ll inf=1e9+10;
ll n;
ll a[maxn];
int main()
{
IOS
cin>>n;
ll sum=0;
for(ll i=0;i<n;i++)cin>>a[i],sum+=a[i];;
sort(a,a+n);
for(ll i=n-3;i>=0;i-=3){
sum-=a[i];
}
cout<<sum<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
14 ms |
1536 KB |
Output is correct |
7 |
Correct |
10 ms |
1536 KB |
Output is correct |
8 |
Correct |
10 ms |
1536 KB |
Output is correct |
9 |
Correct |
18 ms |
1664 KB |
Output is correct |
10 |
Correct |
18 ms |
1664 KB |
Output is correct |