This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#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;