This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int nx=5e3+5;
#define ll long long
ll n, m, dist[nx][nx], u, v, w, dp[nx], mx;
vector<tuple<ll, ll, ll>> d;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>m;
for (int i=1; i<=m; i++) cin>>u>>v>>w, dist[u][v]=w, dist[v][u]=w, d.push_back({u, v, w}), dp[u]+=w, dp[v]+=w;
for (int i=1; i<=n; i++) mx=max(mx, dp[i]);
for (auto [u, v, w]:d) for (int i=1; i<=n; i++) if (dist[u][i]!=0&&dist[v][i]!=0) mx=max(mx, w+dist[u][i]+dist[v][i]);
cout<<mx;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |