#include<iostream>
#include<vector>
#include<set>
//#include<map>
#define INF 999999999
#define ll long long
const int NMAX=500005;
std::vector<ll>v(NMAX);
//std::map<std::pair<int, int>, bool>mp;
std::set<std::pair<int, ll>>G[NMAX];
ll ans=0;
int n, m;
inline void verifyCommon(int x, int y, ll cost)
{
for(auto it:G[x])
{
int node=it.first;
auto pos=G[y].lower_bound({node, -INF});
if(pos!=G[y].end() && pos->first==node)
ans=std::max(ans, pos->second+cost+it.second);
}
}
int main()
{
std::cin>>n>>m;
for(int i=0; i<m; ++i)
{
int from, to, cost;
std::cin>>from>>to>>cost;
v[from]+=cost;
v[to]+=cost;
//if(to<from)
// std::swap(to, from);
//mp[{from, to}]=true;
verifyCommon(from, to, cost);
G[from].insert({to, cost});
G[to].insert({from, cost});
}
for(int i=1; i<=n; ++i)
ans=std::max(ans, v[i]);
std::cout<<ans;
return 0;
}
# | 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... |