# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
98759 | M_H_H_7 | Akcija (COCI15_akcija) | C++14 | 25 ms | 1664 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//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);
ll i = 0;
if(n % 3 == 1)ans += a[0],i++;
if(n % 3 == 2)ans += a[1],i++;
for(i;i < n;i += 3)ans += (a[i + 1] + a[i + 2]);
cout << ans;
return 0;
}
//Written by M_H_H_7
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |