Submission

Status:
[-SSSS][-SSSS][-SSSS][-S][-][-][-][-][-S][-S]

Score: 0

User: catcatcat

Problemset: โดรน

Language: cpp

Time: 0.003 second

Submitted On: 2024-11-25 00:39:59

#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;

// Utility functions for input/output optimization
void setALL() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

void setIn() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void setOut() {
    ios_base::sync_with_stdio(false);
    cout.tie(NULL);
}

void print_case(int i) {
    cout << "Case #" << i << ": ";
}

/* --- Work Space --- */
int main() {
    int n, result = 0, drone = 0;
    int use[1002] = {0};
    vector<int> heights;

    cin >> n;

    // Simulate the heights (replace the placeholder with actual input if needed)
    for (int i = 0; i < n; ++i) {
        heights.push_back(i);
    }

    // Sort heights in descending order
    sort(heights.begin(), heights.end(), greater<int>());

    use[0] = 10;

    for (int i = 0; i < n; ++i) {
        if (use[drone] == 10) {
            // Condition 1: if the current drone is fully utilized
            drone++;
            result += heights[i] * drone;
            use[drone]++;
           // cout << "c1" << endl;
        } else if (use[drone] == 1) {
            // Condition 2: if the current drone has minimal usage
            drone++;
            if (use[drone / 2] < 10) {
                // Adjust usage of the half-capacity drone
                use[drone / 2]++;
                result += heights[i] * drone;
                drone--;
             //   cout << "c2.1 " << drone << " result=" << result << " " << heights[i] * drone << endl;
            } else {
                result += heights[i] * drone;
                use[drone]++;
               // cout << "c2.2" << endl;
            }
        } else {
            // Condition 3: otherwise, apply double weight for the drone
            result += heights[i] * drone * 2;
            use[drone]++;
            //cout << "c3" << endl;
        }

        // Debugging output
       // cout << "i=" << i << " drone=" << drone << " result=" << result << endl;
      //  for (int j = 0; j < 20; ++j) {
        //    cout << use[j] << " ";
        //}
       // cout << endl << endl;
    }

    cout << result;
}