Submission
Status:
[PPPPP][PPPPP][PPPPP][PP][P][P][P][P][PP][PP]
Score: 100
User: catcatcat
Problemset: โดรน
Language: cpp
Time: 0.002 second
Submitted On: 2024-11-25 00:46:35
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define pii pair<pi, pi>
#define pl pair<ll, ll>
#define st first
#define nd second
using namespace std;
typedef double db;
const int MX = 1e9 + 7;
const int LM = INT_MAX;
const int TM = 1e7 + 2;
const int TT = 1e3 + 2;
int main() {
int n, result = 0, drone = 0;
int use[1002] = {0};
vector<int> heights;
cin >> n;
int x;
for (int i = 0; i < n; ++i) {
cin >> x;
heights.push_back(x);
}
sort(heights.begin(), heights.end(), greater<int>());
use[0] = 10;
for (int i = 0; i < n; ++i) {
if (use[drone] == 10) {
drone++;
result += heights[i] * drone;
use[drone]++;
} else if (use[drone] == 1) {
drone++;
if (use[drone / 2] < 10) {
use[drone / 2]++;
result += heights[i] * drone;
drone--;
} else {
result += heights[i] * drone;
use[drone]++;
}
} else {
result += heights[i] * drone * 2;
use[drone]++;
}
}
cout << result;
}