# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
98760 |
2019-02-25T16:16:08 Z |
M_H_H_7 |
Akcija (COCI15_akcija) |
C++14 |
|
20 ms |
1280 KB |
//In The Name of Beauty
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define IB std::ios::sync_with_stdio(0);
#define pb(x) push_back(x);
#define mp(x,y) make_pair(x,y)
#define pll pair<ll,ll>
#define F first
#define S second
ll const MAXN = 1e5 + 8;
ll const INF = 1e12 + 8;
ll const delta = 1000000007;
int main()
{
IB;
cin.tie(0);
cout.tie(0);
ll n;
cin >> n;
ll a[n];
ll ans = 0;
for(ll i = 0;i < n;i++)cin >> a[i];
sort(a,a + n);
for(ll i = n - 1;i >= 0;i -= 3)
{
if(i == 0)
{
ans += a[0];
}
else if(i == 1)
{
ans += a[0];
ans += a[1];
}
else
{
ans += a[i];
ans += a[i - 1];
}
}
cout << ans;
return 0;
}
//Written by M_H_H_7
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
17 ms |
1152 KB |
Output is correct |
7 |
Correct |
11 ms |
1152 KB |
Output is correct |
8 |
Correct |
12 ms |
1280 KB |
Output is correct |
9 |
Correct |
18 ms |
1152 KB |
Output is correct |
10 |
Correct |
20 ms |
1152 KB |
Output is correct |