比赛 2025暑期集训第4场 评测结果 AAATT
题目名称 环路运输 最终得分 60
用户昵称 对立猫猫对立 运行时间 4.133 s
代码语言 C++ 内存使用 5.20 MiB
提交时间 2025-07-05 09:59:12
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
int a[2000005];
//大根堆
priority_queue<int, vector<int>, less<int> > q;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    freopen("transportt.in", "r", stdin);
    freopen("transportt.out", "w", stdout);
    int n;
    cin >> n;
    int cmp = n / 2;
    for (int i = 1; i <= n; ++i) cin >> a[i], a[i + n] = a[i];
    int ans = 0;
    for (int i = 1; i <= n * 2; ++i) {
        for (int j = i - cmp; j < i; ++j) {
            if (j < 1) continue;
            ans = max(ans, a[i] + a[j] + i - j);
        }
    }
    cout << ans << endl;
    return 0;
}