好难,还好有高人指点
2023-03-05 10:12:31
发布于:江苏
65阅读
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;
}
这里空空如也
有帮助,赞一个