Files
python/TangDou/CSP-J/AcWingTraining/T6/444.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

32 lines
816 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
const int N = 510;
int n;
int w[N][N];
int main() {
cin >> n;
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++) {
cin >> w[i][j];
w[j][i] = w[i][j];
}
int res = 0;
for (int i = 0; i < n; i++) {
int x = 0, y = 0; // 最大值,次大值
for (int j = 0; j < n; j++)
if (w[i][j] > x) // 更新最大值
y = x, x = w[i][j]; // 旧的最大值退化为次大值
else
y = max(y, w[i][j]); // 可能更新次大值
res = max(res, y); // 每一行的次大值,放在一起PK出最大值
}
// 全都必胜
cout << 1 << endl;
cout << res << endl;
return 0;
}