题解
2023-03-04 18:00:07
发布于:上海
173阅读
0回复
0点赞
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int n,m,v[505];
struct node
{
int x,y,zhi;
bool operator<(const node b)const
{
return zhi > b.zhi;
}
}a[250000];
int main(void)
{
ios::sync_with_stdio(0),cin.tie(0);
int i,j,k = 1;
cin >> n;
for (i = 1; i <= n - 1; i++)
{
for (j = i + 1; j <= n; j++)
{
cin >> a[k].zhi;
a[k].x = i,a[k].y = j;
k++;
}
}
m = n * (n - 1) / 2;
sort(a + 1,a + m + 1);
for (i = 1;i <= m;i++)
{
if (v[a[i].x] == 0 && v[a[i].y] == 0)
{
v[a[i].x] = v[a[i].y] = 1;
}
else
{
cout << 1 << endl;
cout << a[i].zhi;
return 0;
}
}
cout << 0;
return 0;
}
全部评论 1
666明着抄题解
2024-08-24 来自 湖南
0
有帮助,赞一个