제출 #98760

#제출 시각아이디문제언어결과실행 시간메모리
98760M_H_H_7Akcija (COCI15_akcija)C++14
80 / 80
20 ms1280 KiB
//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 timeMemoryGrader output
Fetching results...