#include<iostream>
#include<vector>
#include<set>
#include<map>
#define ll long long
const int NMAX=500005;
std::vector<ll>v(NMAX);
std::map<std::pair<int, int>, std::pair<bool, ll>>mp;
ll ans=0;
int n, m;
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, cost};
}
for(int i=1; i<=n-2; ++i)
for(int j=i+1; j<=n-1; ++j)
for(int k=j+1; k<=n; ++k)
{
if(mp[{i, j}].first && mp[{i, k}].first && mp[{j, k}].first)
ans=std::max(ans, mp[{i, j}].second+mp[{i, k}].second+mp[{j, k}].second);
}
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... |