Code C++14 cho bài chở hàng
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    sort(a.begin(), a.end());

    int i = 0, j = n - 1;
    long long res = 0;

    while (i <= j) {
        long long max_w = a[j];
        j--;

        if (i <= j) i++;
        if (i <= j) i++;

        res += 60 + 5 * max_w;
    }

    cout << res;
    return 0;
}

Bình luận

Mới nhất
Tải bình luận...

Không có bình luận nào.