比赛 |
2025暑期集训第4场 |
评测结果 |
RRRRR |
题目名称 |
环路运输 |
最终得分 |
0 |
用户昵称 |
LikableP |
运行时间 |
9.990 s |
代码语言 |
C++ |
内存使用 |
1.35 MiB |
提交时间 |
2025-07-05 10:46:32 |
显示代码纯文本
#include <cstdio>
template <typename T> T read();
template <typename T> void write(T, char);
template <typename T> T min(T, T);
template <typename T> T max(T, T);
const int MAXN = 1e6 + 10;
int n;
int a[MAXN];
int maxx = -1;
inline int dis(int i, int j) {
return min(j - i, n - (j - i));
}
int main() {
freopen("strategic.in", "r", stdin);
freopen("strategic.out", "w", stdout);
n = read<int>();
for (int i = 1; i <= n; ++i) {
a[i] = read<int>();
}
for (int i = 1; i <= n; ++i) {
for (int j = i + 1; j <= n; ++j) {
maxx = max(maxx, dis(i, j) + a[i] + a[j]);
}
}
write(maxx, '\n');
return 0;
}
template <typename T> T min(T x, T y) {
return x < y ? x : y;
}
template <typename T> T max(T x, T y) {
return x > y ? x : y;
}
#define isdigit(ch) (ch >= '0' && ch <= '9')
template <typename T> T read() {
T res = 0, f = 1;
char ch = getchar();
for (; !isdigit(ch); ch = getchar())
if (ch == '-') f = -1;
for (; isdigit(ch); ch = getchar()) res = (res << 3) + (res << 1) + (ch ^ 48);
return res * f;
}
template <typename T> void write(T x, char ed) {
if (x < 0) x = -x, putchar('-');
static int sta[sizeof(T) << 2], top = 0;
do {
sta[++top] = x % 10;
x /= 10;
} while (x);
while (top) {
putchar(sta[top--] ^ 48);
}
putchar(ed);
}